Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / cookies / cookie_store.h
index b2552a6..9f5e1f1 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "base/basictypes.h"
 #include "base/callback.h"
+#include "base/callback_list.h"
 #include "base/memory/ref_counted.h"
 #include "base/time/time.h"
 #include "net/base/net_export.h"
@@ -33,6 +34,11 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
   typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback;
   typedef base::Callback<void(bool success)> SetCookiesCallback;
   typedef base::Callback<void(int num_deleted)> DeleteCallback;
+  typedef base::Callback<void(const CanonicalCookie& cookie, bool removed)>
+      CookieChangedCallback;
+  typedef base::CallbackList<void(const CanonicalCookie& cookie, bool removed)>
+      CookieChangedCallbackList;
+  typedef CookieChangedCallbackList::Subscription CookieChangedSubscription;
 
   // Sets a single cookie.  Expects a cookie line, like "a=1; domain=b.com".
   //
@@ -91,6 +97,27 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
   // Returns the underlying CookieMonster.
   virtual CookieMonster* GetCookieMonster() = 0;
 
+  // Add a callback to be notified when the set of cookies named |name| that
+  // would be sent for a request to |url| changes. The returned handle is
+  // guaranteed not to hold a hard reference to the CookieStore object.
+  //
+  // |callback| will be called when a cookie is added or removed. |callback| is
+  // passed the respective |cookie| which was added to or removed from the
+  // cookies and a boolean indicating if the cookies was removed or not.
+  //
+  // Note that |callback| is called twice when a cookie is updated: once for
+  // the removal of the existing cookie and once for the adding the new cookie.
+  //
+  // Note that this method consumes memory and CPU per (url, name) pair ever
+  // registered that are still consumed even after all subscriptions for that
+  // (url, name) pair are removed. If this method ever needs to support an
+  // unbounded amount of such pairs, this contract needs to change and
+  // implementors need to be improved to not behave this way.
+  virtual scoped_ptr<CookieChangedSubscription> AddCallbackForCookie(
+      const GURL& url,
+      const std::string& name,
+      const CookieChangedCallback& callback) = 0;
+
  protected:
   friend class base::RefCountedThreadSafe<CookieStore>;
   CookieStore();