| OLD | NEW | 
|     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 // Portions of this code based on Mozilla: |     5 // Portions of this code based on Mozilla: | 
|     6 //   (netwerk/cookie/src/nsCookieService.cpp) |     6 //   (netwerk/cookie/src/nsCookieService.cpp) | 
|     7 /* ***** BEGIN LICENSE BLOCK ***** |     7 /* ***** BEGIN LICENSE BLOCK ***** | 
|     8  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |     8  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 
|     9  * |     9  * | 
|    10  * The contents of this file are subject to the Mozilla Public License Version |    10  * The contents of this file are subject to the Mozilla Public License Version | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    97 // See comments at declaration of these variables in cookie_monster.h |    97 // See comments at declaration of these variables in cookie_monster.h | 
|    98 // for details. |    98 // for details. | 
|    99 const size_t CookieMonster::kDomainMaxCookies           = 180; |    99 const size_t CookieMonster::kDomainMaxCookies           = 180; | 
|   100 const size_t CookieMonster::kDomainPurgeCookies         = 30; |   100 const size_t CookieMonster::kDomainPurgeCookies         = 30; | 
|   101 const size_t CookieMonster::kMaxCookies                 = 3300; |   101 const size_t CookieMonster::kMaxCookies                 = 3300; | 
|   102 const size_t CookieMonster::kPurgeCookies               = 300; |   102 const size_t CookieMonster::kPurgeCookies               = 300; | 
|   103  |   103  | 
|   104 const size_t CookieMonster::kDomainCookiesQuotaLow    = 30; |   104 const size_t CookieMonster::kDomainCookiesQuotaLow    = 30; | 
|   105 const size_t CookieMonster::kDomainCookiesQuotaMedium = 50; |   105 const size_t CookieMonster::kDomainCookiesQuotaMedium = 50; | 
|   106 const size_t CookieMonster::kDomainCookiesQuotaHigh   = |   106 const size_t CookieMonster::kDomainCookiesQuotaHigh   = | 
|   107     CookieMonster::kDomainMaxCookies - CookieMonster::kDomainPurgeCookies |   107     kDomainMaxCookies - kDomainPurgeCookies | 
|   108     - CookieMonster::kDomainCookiesQuotaLow |   108     - kDomainCookiesQuotaLow - kDomainCookiesQuotaMedium; | 
|   109     - CookieMonster::kDomainCookiesQuotaMedium; |  | 
|   110  |   109  | 
|   111 const int CookieMonster::kSafeFromGlobalPurgeDays       = 30; |   110 const int CookieMonster::kSafeFromGlobalPurgeDays       = 30; | 
|   112  |   111  | 
|   113 namespace { |   112 namespace { | 
|   114  |   113  | 
|   115 typedef std::vector<CanonicalCookie*> CanonicalCookieVector; |   114 typedef std::vector<CanonicalCookie*> CanonicalCookieVector; | 
|   116  |   115  | 
|   117 // Default minimum delay after updating a cookie's LastAccessDate before we |   116 // Default minimum delay after updating a cookie's LastAccessDate before we | 
|   118 // will update it again. |   117 // will update it again. | 
|   119 const int kDefaultAccessUpdateThresholdSeconds = 60; |   118 const int kDefaultAccessUpdateThresholdSeconds = 60; | 
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   392 // message loop because the underlying instance may be destroyed (along with the |   391 // message loop because the underlying instance may be destroyed (along with the | 
|   393 // CookieMonsterTask instance) in the interim. Therefore, we post a callback |   392 // CookieMonsterTask instance) in the interim. Therefore, we post a callback | 
|   394 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing |   393 // bound to the CookieMonsterTask, which *is* reference counted (thus preventing | 
|   395 // destruction of the original callback), and which invokes the closure (which |   394 // destruction of the original callback), and which invokes the closure (which | 
|   396 // invokes the original callback with the returned data). |   395 // invokes the original callback with the returned data). | 
|   397 void CookieMonster::CookieMonsterTask::InvokeCallback(base::Closure callback) { |   396 void CookieMonster::CookieMonsterTask::InvokeCallback(base::Closure callback) { | 
|   398   if (thread_->BelongsToCurrentThread()) { |   397   if (thread_->BelongsToCurrentThread()) { | 
|   399     callback.Run(); |   398     callback.Run(); | 
|   400   } else { |   399   } else { | 
|   401     thread_->PostTask(FROM_HERE, base::Bind( |   400     thread_->PostTask(FROM_HERE, base::Bind( | 
|   402         &CookieMonster::CookieMonsterTask::InvokeCallback, this, callback)); |   401         &CookieMonsterTask::InvokeCallback, this, callback)); | 
|   403   } |   402   } | 
|   404 } |   403 } | 
|   405  |   404  | 
|   406 // Task class for SetCookieWithDetails call. |   405 // Task class for SetCookieWithDetails call. | 
|   407 class CookieMonster::SetCookieWithDetailsTask |   406 class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask { | 
|   408     : public CookieMonster::CookieMonsterTask { |  | 
|   409  public: |   407  public: | 
|   410   SetCookieWithDetailsTask(CookieMonster* cookie_monster, |   408   SetCookieWithDetailsTask(CookieMonster* cookie_monster, | 
|   411                            const GURL& url, |   409                            const GURL& url, | 
|   412                            const std::string& name, |   410                            const std::string& name, | 
|   413                            const std::string& value, |   411                            const std::string& value, | 
|   414                            const std::string& domain, |   412                            const std::string& domain, | 
|   415                            const std::string& path, |   413                            const std::string& path, | 
|   416                            const base::Time& expiration_time, |   414                            const base::Time& expiration_time, | 
|   417                            bool secure, |   415                            bool secure, | 
|   418                            bool http_only, |   416                            bool http_only, | 
|   419                            CookiePriority priority, |   417                            CookiePriority priority, | 
|   420                            const CookieMonster::SetCookiesCallback& callback) |   418                            const SetCookiesCallback& callback) | 
|   421       : CookieMonsterTask(cookie_monster), |   419       : CookieMonsterTask(cookie_monster), | 
|   422         url_(url), |   420         url_(url), | 
|   423         name_(name), |   421         name_(name), | 
|   424         value_(value), |   422         value_(value), | 
|   425         domain_(domain), |   423         domain_(domain), | 
|   426         path_(path), |   424         path_(path), | 
|   427         expiration_time_(expiration_time), |   425         expiration_time_(expiration_time), | 
|   428         secure_(secure), |   426         secure_(secure), | 
|   429         http_only_(http_only), |   427         http_only_(http_only), | 
|   430         priority_(priority), |   428         priority_(priority), | 
|   431         callback_(callback) { |   429         callback_(callback) { | 
|   432   } |   430   } | 
|   433  |   431  | 
|   434   // CookieMonster::CookieMonsterTask: |   432   // CookieMonsterTask: | 
|   435   virtual void Run() OVERRIDE; |   433   virtual void Run() OVERRIDE; | 
|   436  |   434  | 
|   437  protected: |   435  protected: | 
|   438   virtual ~SetCookieWithDetailsTask() {} |   436   virtual ~SetCookieWithDetailsTask() {} | 
|   439  |   437  | 
|   440  private: |   438  private: | 
|   441   GURL url_; |   439   GURL url_; | 
|   442   std::string name_; |   440   std::string name_; | 
|   443   std::string value_; |   441   std::string value_; | 
|   444   std::string domain_; |   442   std::string domain_; | 
|   445   std::string path_; |   443   std::string path_; | 
|   446   base::Time expiration_time_; |   444   base::Time expiration_time_; | 
|   447   bool secure_; |   445   bool secure_; | 
|   448   bool http_only_; |   446   bool http_only_; | 
|   449   CookiePriority priority_; |   447   CookiePriority priority_; | 
|   450   CookieMonster::SetCookiesCallback callback_; |   448   SetCookiesCallback callback_; | 
|   451  |   449  | 
|   452   DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); |   450   DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); | 
|   453 }; |   451 }; | 
|   454  |   452  | 
|   455 void CookieMonster::SetCookieWithDetailsTask::Run() { |   453 void CookieMonster::SetCookieWithDetailsTask::Run() { | 
|   456   bool success = this->cookie_monster()-> |   454   bool success = this->cookie_monster()-> | 
|   457       SetCookieWithDetails(url_, name_, value_, domain_, path_, |   455       SetCookieWithDetails(url_, name_, value_, domain_, path_, | 
|   458                            expiration_time_, secure_, http_only_, priority_); |   456                            expiration_time_, secure_, http_only_, priority_); | 
|   459   if (!callback_.is_null()) { |   457   if (!callback_.is_null()) { | 
|   460     this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, |   458     this->InvokeCallback(base::Bind(&SetCookiesCallback::Run, | 
|   461                                     base::Unretained(&callback_), success)); |   459                                     base::Unretained(&callback_), success)); | 
|   462   } |   460   } | 
|   463 } |   461 } | 
|   464  |   462  | 
|   465 // Task class for GetAllCookies call. |   463 // Task class for GetAllCookies call. | 
|   466 class CookieMonster::GetAllCookiesTask |   464 class CookieMonster::GetAllCookiesTask : public CookieMonsterTask { | 
|   467     : public CookieMonster::CookieMonsterTask { |  | 
|   468  public: |   465  public: | 
|   469   GetAllCookiesTask(CookieMonster* cookie_monster, |   466   GetAllCookiesTask(CookieMonster* cookie_monster, | 
|   470                     const CookieMonster::GetCookieListCallback& callback) |   467                     const GetCookieListCallback& callback) | 
|   471       : CookieMonsterTask(cookie_monster), |   468       : CookieMonsterTask(cookie_monster), | 
|   472         callback_(callback) { |   469         callback_(callback) { | 
|   473   } |   470   } | 
|   474  |   471  | 
|   475   // CookieMonster::CookieMonsterTask |   472   // CookieMonsterTask | 
|   476   virtual void Run() OVERRIDE; |   473   virtual void Run() OVERRIDE; | 
|   477  |   474  | 
|   478  protected: |   475  protected: | 
|   479   virtual ~GetAllCookiesTask() {} |   476   virtual ~GetAllCookiesTask() {} | 
|   480  |   477  | 
|   481  private: |   478  private: | 
|   482   CookieMonster::GetCookieListCallback callback_; |   479   GetCookieListCallback callback_; | 
|   483  |   480  | 
|   484   DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); |   481   DISALLOW_COPY_AND_ASSIGN(GetAllCookiesTask); | 
|   485 }; |   482 }; | 
|   486  |   483  | 
|   487 void CookieMonster::GetAllCookiesTask::Run() { |   484 void CookieMonster::GetAllCookiesTask::Run() { | 
|   488   if (!callback_.is_null()) { |   485   if (!callback_.is_null()) { | 
|   489     CookieList cookies = this->cookie_monster()->GetAllCookies(); |   486     CookieList cookies = this->cookie_monster()->GetAllCookies(); | 
|   490     this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |   487     this->InvokeCallback(base::Bind(&GetCookieListCallback::Run, | 
|   491                                     base::Unretained(&callback_), cookies)); |   488                                     base::Unretained(&callback_), cookies)); | 
|   492     } |   489     } | 
|   493 } |   490 } | 
|   494  |   491  | 
|   495 // Task class for GetAllCookiesForURLWithOptions call. |   492 // Task class for GetAllCookiesForURLWithOptions call. | 
|   496 class CookieMonster::GetAllCookiesForURLWithOptionsTask |   493 class CookieMonster::GetAllCookiesForURLWithOptionsTask | 
|   497     : public CookieMonster::CookieMonsterTask { |   494     : public CookieMonsterTask { | 
|   498  public: |   495  public: | 
|   499   GetAllCookiesForURLWithOptionsTask( |   496   GetAllCookiesForURLWithOptionsTask( | 
|   500       CookieMonster* cookie_monster, |   497       CookieMonster* cookie_monster, | 
|   501       const GURL& url, |   498       const GURL& url, | 
|   502       const CookieOptions& options, |   499       const CookieOptions& options, | 
|   503       const CookieMonster::GetCookieListCallback& callback) |   500       const GetCookieListCallback& callback) | 
|   504       : CookieMonsterTask(cookie_monster), |   501       : CookieMonsterTask(cookie_monster), | 
|   505         url_(url), |   502         url_(url), | 
|   506         options_(options), |   503         options_(options), | 
|   507         callback_(callback) { |   504         callback_(callback) { | 
|   508   } |   505   } | 
|   509  |   506  | 
|   510   // CookieMonster::CookieMonsterTask: |   507   // CookieMonsterTask: | 
|   511   virtual void Run() OVERRIDE; |   508   virtual void Run() OVERRIDE; | 
|   512  |   509  | 
|   513  protected: |   510  protected: | 
|   514   virtual ~GetAllCookiesForURLWithOptionsTask() {} |   511   virtual ~GetAllCookiesForURLWithOptionsTask() {} | 
|   515  |   512  | 
|   516  private: |   513  private: | 
|   517   GURL url_; |   514   GURL url_; | 
|   518   CookieOptions options_; |   515   CookieOptions options_; | 
|   519   CookieMonster::GetCookieListCallback callback_; |   516   GetCookieListCallback callback_; | 
|   520  |   517  | 
|   521   DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); |   518   DISALLOW_COPY_AND_ASSIGN(GetAllCookiesForURLWithOptionsTask); | 
|   522 }; |   519 }; | 
|   523  |   520  | 
|   524 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { |   521 void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() { | 
|   525   if (!callback_.is_null()) { |   522   if (!callback_.is_null()) { | 
|   526     CookieList cookies = this->cookie_monster()-> |   523     CookieList cookies = this->cookie_monster()-> | 
|   527         GetAllCookiesForURLWithOptions(url_, options_); |   524         GetAllCookiesForURLWithOptions(url_, options_); | 
|   528     this->InvokeCallback(base::Bind(&CookieMonster::GetCookieListCallback::Run, |   525     this->InvokeCallback(base::Bind(&GetCookieListCallback::Run, | 
|   529                                     base::Unretained(&callback_), cookies)); |   526                                     base::Unretained(&callback_), cookies)); | 
|   530   } |   527   } | 
|   531 } |   528 } | 
|   532  |   529  | 
|   533 // Task class for DeleteAll call. |   530 template <typename Result> struct CallbackType { | 
|   534 class CookieMonster::DeleteAllTask : public CookieMonster::CookieMonsterTask { |   531   typedef base::Callback<void(Result)> Type; | 
 |   532 }; | 
 |   533  | 
 |   534 template <> struct CallbackType<void> { | 
 |   535   typedef base::Closure Type; | 
 |   536 }; | 
 |   537  | 
 |   538 // Base task class for Delete*Task. | 
 |   539 template <typename Result> | 
 |   540 class CookieMonster::DeleteTask : public CookieMonsterTask { | 
|   535  public: |   541  public: | 
|   536   DeleteAllTask(CookieMonster* cookie_monster, |   542   DeleteTask(CookieMonster* cookie_monster, | 
|   537                 const CookieMonster::DeleteCallback& callback) |   543              const typename CallbackType<Result>::Type& callback) | 
|   538       : CookieMonsterTask(cookie_monster), |   544       : CookieMonsterTask(cookie_monster), | 
|   539         callback_(callback) { |   545         callback_(callback) { | 
|   540   } |   546   } | 
|   541  |   547  | 
|   542   // CookieMonster::CookieMonsterTask: |   548   // CookieMonsterTask: | 
|   543   virtual void Run() OVERRIDE; |   549   virtual void Run() OVERRIDE; | 
|   544  |   550  | 
 |   551  private: | 
 |   552   // Runs the delete task and returns a result. | 
 |   553   virtual Result RunDeleteTask() = 0; | 
 |   554   base::Closure RunDeleteTaskAndBindCallback(); | 
 |   555   void FlushDone(const base::Closure& callback); | 
 |   556  | 
 |   557   typename CallbackType<Result>::Type callback_; | 
 |   558  | 
 |   559   DISALLOW_COPY_AND_ASSIGN(DeleteTask); | 
 |   560 }; | 
 |   561  | 
 |   562 template <typename Result> | 
 |   563 base::Closure CookieMonster::DeleteTask<Result>:: | 
 |   564 RunDeleteTaskAndBindCallback() { | 
 |   565   Result result = RunDeleteTask(); | 
 |   566   if (callback_.is_null()) | 
 |   567     return base::Closure(); | 
 |   568   return base::Bind(callback_, result); | 
 |   569 } | 
 |   570  | 
 |   571 template <> | 
 |   572 base::Closure CookieMonster::DeleteTask<void>::RunDeleteTaskAndBindCallback() { | 
 |   573   RunDeleteTask(); | 
 |   574   return callback_; | 
 |   575 } | 
 |   576  | 
 |   577 template <typename Result> | 
 |   578 void CookieMonster::DeleteTask<Result>::Run() { | 
 |   579   this->cookie_monster()->FlushStore( | 
 |   580       base::Bind(&DeleteTask<Result>::FlushDone, this, | 
 |   581                  RunDeleteTaskAndBindCallback())); | 
 |   582 } | 
 |   583  | 
 |   584 template <typename Result> | 
 |   585 void CookieMonster::DeleteTask<Result>::FlushDone( | 
 |   586     const base::Closure& callback) { | 
 |   587   if (!callback.is_null()) { | 
 |   588     this->InvokeCallback(callback); | 
 |   589   } | 
 |   590 } | 
 |   591  | 
 |   592 // Task class for DeleteAll call. | 
 |   593 class CookieMonster::DeleteAllTask : public DeleteTask<int> { | 
 |   594  public: | 
 |   595   DeleteAllTask(CookieMonster* cookie_monster, | 
 |   596                 const DeleteCallback& callback) | 
 |   597       : DeleteTask(cookie_monster, callback) { | 
 |   598   } | 
 |   599  | 
 |   600   // DeleteTask: | 
 |   601   virtual int RunDeleteTask() OVERRIDE; | 
 |   602  | 
|   545  protected: |   603  protected: | 
|   546   virtual ~DeleteAllTask() {} |   604   virtual ~DeleteAllTask() {} | 
|   547  |   605  | 
|   548  private: |   606  private: | 
|   549   CookieMonster::DeleteCallback callback_; |  | 
|   550  |  | 
|   551   DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); |   607   DISALLOW_COPY_AND_ASSIGN(DeleteAllTask); | 
|   552 }; |   608 }; | 
|   553  |   609  | 
|   554 void CookieMonster::DeleteAllTask::Run() { |   610 int CookieMonster::DeleteAllTask::RunDeleteTask() { | 
|   555   int num_deleted = this->cookie_monster()->DeleteAll(true); |   611   return this->cookie_monster()->DeleteAll(true); | 
|   556   if (!callback_.is_null()) { |  | 
|   557     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |  | 
|   558                                     base::Unretained(&callback_), num_deleted)); |  | 
|   559   } |  | 
|   560 } |   612 } | 
|   561  |   613  | 
|   562 // Task class for DeleteAllCreatedBetween call. |   614 // Task class for DeleteAllCreatedBetween call. | 
|   563 class CookieMonster::DeleteAllCreatedBetweenTask |   615 class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> { | 
|   564     : public CookieMonster::CookieMonsterTask { |  | 
|   565  public: |   616  public: | 
|   566   DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, |   617   DeleteAllCreatedBetweenTask(CookieMonster* cookie_monster, | 
|   567                               const Time& delete_begin, |   618                               const Time& delete_begin, | 
|   568                               const Time& delete_end, |   619                               const Time& delete_end, | 
|   569                               const CookieMonster::DeleteCallback& callback) |   620                               const DeleteCallback& callback) | 
|   570       : CookieMonsterTask(cookie_monster), |   621       : DeleteTask(cookie_monster, callback), | 
|   571         delete_begin_(delete_begin), |   622         delete_begin_(delete_begin), | 
|   572         delete_end_(delete_end), |   623         delete_end_(delete_end) { | 
|   573         callback_(callback) { |  | 
|   574   } |   624   } | 
|   575  |   625  | 
|   576   // CookieMonster::CookieMonsterTask: |   626   // DeleteTask: | 
|   577   virtual void Run() OVERRIDE; |   627   virtual int RunDeleteTask() OVERRIDE; | 
|   578  |   628  | 
|   579  protected: |   629  protected: | 
|   580   virtual ~DeleteAllCreatedBetweenTask() {} |   630   virtual ~DeleteAllCreatedBetweenTask() {} | 
|   581  |   631  | 
|   582  private: |   632  private: | 
|   583   Time delete_begin_; |   633   Time delete_begin_; | 
|   584   Time delete_end_; |   634   Time delete_end_; | 
|   585   CookieMonster::DeleteCallback callback_; |  | 
|   586  |   635  | 
|   587   DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); |   636   DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenTask); | 
|   588 }; |   637 }; | 
|   589  |   638  | 
|   590 void CookieMonster::DeleteAllCreatedBetweenTask::Run() { |   639 int CookieMonster::DeleteAllCreatedBetweenTask::RunDeleteTask() { | 
|   591   int num_deleted = this->cookie_monster()-> |   640   return this->cookie_monster()-> | 
|   592       DeleteAllCreatedBetween(delete_begin_, delete_end_); |   641       DeleteAllCreatedBetween(delete_begin_, delete_end_); | 
|   593   if (!callback_.is_null()) { |  | 
|   594     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |  | 
|   595                                     base::Unretained(&callback_), num_deleted)); |  | 
|   596   } |  | 
|   597 } |   642 } | 
|   598  |   643  | 
|   599 // Task class for DeleteAllForHost call. |   644 // Task class for DeleteAllForHost call. | 
|   600 class CookieMonster::DeleteAllForHostTask |   645 class CookieMonster::DeleteAllForHostTask : public DeleteTask<int> { | 
|   601     : public CookieMonster::CookieMonsterTask { |  | 
|   602  public: |   646  public: | 
|   603   DeleteAllForHostTask(CookieMonster* cookie_monster, |   647   DeleteAllForHostTask(CookieMonster* cookie_monster, | 
|   604                        const GURL& url, |   648                        const GURL& url, | 
|   605                        const CookieMonster::DeleteCallback& callback) |   649                        const DeleteCallback& callback) | 
|   606       : CookieMonsterTask(cookie_monster), |   650       : DeleteTask(cookie_monster, callback), | 
|   607         url_(url), |   651         url_(url) { | 
|   608         callback_(callback) { |  | 
|   609   } |   652   } | 
|   610  |   653  | 
|   611   // CookieMonster::CookieMonsterTask: |   654   // DeleteTask: | 
|   612   virtual void Run() OVERRIDE; |   655   virtual int RunDeleteTask() OVERRIDE; | 
|   613  |   656  | 
|   614  protected: |   657  protected: | 
|   615   virtual ~DeleteAllForHostTask() {} |   658   virtual ~DeleteAllForHostTask() {} | 
|   616  |   659  | 
|   617  private: |   660  private: | 
|   618   GURL url_; |   661   GURL url_; | 
|   619   CookieMonster::DeleteCallback callback_; |  | 
|   620  |   662  | 
|   621   DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); |   663   DISALLOW_COPY_AND_ASSIGN(DeleteAllForHostTask); | 
|   622 }; |   664 }; | 
|   623  |   665  | 
|   624 void CookieMonster::DeleteAllForHostTask::Run() { |   666 int CookieMonster::DeleteAllForHostTask::RunDeleteTask() { | 
|   625   int num_deleted = this->cookie_monster()->DeleteAllForHost(url_); |   667   return this->cookie_monster()->DeleteAllForHost(url_); | 
|   626   if (!callback_.is_null()) { |  | 
|   627     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |  | 
|   628                                     base::Unretained(&callback_), num_deleted)); |  | 
|   629   } |  | 
|   630 } |   668 } | 
|   631  |   669  | 
|   632 // Task class for DeleteAllCreatedBetweenForHost call. |   670 // Task class for DeleteAllCreatedBetweenForHost call. | 
|   633 class CookieMonster::DeleteAllCreatedBetweenForHostTask |   671 class CookieMonster::DeleteAllCreatedBetweenForHostTask | 
|   634     : public CookieMonster::CookieMonsterTask { |   672     : public DeleteTask<int> { | 
|   635  public: |   673  public: | 
|   636   DeleteAllCreatedBetweenForHostTask( |   674   DeleteAllCreatedBetweenForHostTask( | 
|   637       CookieMonster* cookie_monster, |   675       CookieMonster* cookie_monster, | 
|   638       Time delete_begin, |   676       Time delete_begin, | 
|   639       Time delete_end, |   677       Time delete_end, | 
|   640       const GURL& url, |   678       const GURL& url, | 
|   641       const CookieMonster::DeleteCallback& callback) |   679       const DeleteCallback& callback) | 
|   642       : CookieMonsterTask(cookie_monster), |   680       : DeleteTask(cookie_monster, callback), | 
|   643         delete_begin_(delete_begin), |   681         delete_begin_(delete_begin), | 
|   644         delete_end_(delete_end), |   682         delete_end_(delete_end), | 
|   645         url_(url), |   683         url_(url) { | 
|   646         callback_(callback) { |  | 
|   647   } |   684   } | 
|   648  |   685  | 
|   649   // CookieMonster::CookieMonsterTask: |   686   // DeleteTask: | 
|   650   virtual void Run() OVERRIDE; |   687   virtual int RunDeleteTask() OVERRIDE; | 
|   651  |   688  | 
|   652  protected: |   689  protected: | 
|   653   virtual ~DeleteAllCreatedBetweenForHostTask() {} |   690   virtual ~DeleteAllCreatedBetweenForHostTask() {} | 
|   654  |   691  | 
|   655  private: |   692  private: | 
|   656   Time delete_begin_; |   693   Time delete_begin_; | 
|   657   Time delete_end_; |   694   Time delete_end_; | 
|   658   GURL url_; |   695   GURL url_; | 
|   659   CookieMonster::DeleteCallback callback_; |  | 
|   660  |   696  | 
|   661   DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenForHostTask); |   697   DISALLOW_COPY_AND_ASSIGN(DeleteAllCreatedBetweenForHostTask); | 
|   662 }; |   698 }; | 
|   663  |   699  | 
|   664 void CookieMonster::DeleteAllCreatedBetweenForHostTask::Run() { |   700 int CookieMonster::DeleteAllCreatedBetweenForHostTask::RunDeleteTask() { | 
|   665   int num_deleted = this->cookie_monster()->DeleteAllCreatedBetweenForHost( |   701   return this->cookie_monster()->DeleteAllCreatedBetweenForHost( | 
|   666       delete_begin_, delete_end_, url_); |   702       delete_begin_, delete_end_, url_); | 
|   667   if (!callback_.is_null()) { |  | 
|   668     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |  | 
|   669                                     base::Unretained(&callback_), num_deleted)); |  | 
|   670   } |  | 
|   671 } |   703 } | 
|   672  |   704  | 
|   673 // Task class for DeleteCanonicalCookie call. |   705 // Task class for DeleteCanonicalCookie call. | 
|   674 class CookieMonster::DeleteCanonicalCookieTask |   706 class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<bool> { | 
|   675     : public CookieMonster::CookieMonsterTask { |  | 
|   676  public: |   707  public: | 
|   677   DeleteCanonicalCookieTask(CookieMonster* cookie_monster, |   708   DeleteCanonicalCookieTask(CookieMonster* cookie_monster, | 
|   678                             const CanonicalCookie& cookie, |   709                             const CanonicalCookie& cookie, | 
|   679                             const CookieMonster::DeleteCookieCallback& callback) |   710                             const DeleteCookieCallback& callback) | 
|   680       : CookieMonsterTask(cookie_monster), |   711       : DeleteTask(cookie_monster, callback), | 
|   681         cookie_(cookie), |   712         cookie_(cookie) { | 
|   682         callback_(callback) { |  | 
|   683   } |   713   } | 
|   684  |   714  | 
|   685   // CookieMonster::CookieMonsterTask: |   715   // DeleteTask: | 
|   686   virtual void Run() OVERRIDE; |   716   virtual bool RunDeleteTask() OVERRIDE; | 
|   687  |   717  | 
|   688  protected: |   718  protected: | 
|   689   virtual ~DeleteCanonicalCookieTask() {} |   719   virtual ~DeleteCanonicalCookieTask() {} | 
|   690  |   720  | 
|   691  private: |   721  private: | 
|   692   CanonicalCookie cookie_; |   722   CanonicalCookie cookie_; | 
|   693   CookieMonster::DeleteCookieCallback callback_; |  | 
|   694  |   723  | 
|   695   DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); |   724   DISALLOW_COPY_AND_ASSIGN(DeleteCanonicalCookieTask); | 
|   696 }; |   725 }; | 
|   697  |   726  | 
|   698 void CookieMonster::DeleteCanonicalCookieTask::Run() { |   727 bool CookieMonster::DeleteCanonicalCookieTask::RunDeleteTask() { | 
|   699   bool result = this->cookie_monster()->DeleteCanonicalCookie(cookie_); |   728   return this->cookie_monster()->DeleteCanonicalCookie(cookie_); | 
|   700   if (!callback_.is_null()) { |  | 
|   701     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCookieCallback::Run, |  | 
|   702                                     base::Unretained(&callback_), result)); |  | 
|   703   } |  | 
|   704 } |   729 } | 
|   705  |   730  | 
|   706 // Task class for SetCookieWithOptions call. |   731 // Task class for SetCookieWithOptions call. | 
|   707 class CookieMonster::SetCookieWithOptionsTask |   732 class CookieMonster::SetCookieWithOptionsTask : public CookieMonsterTask { | 
|   708     : public CookieMonster::CookieMonsterTask { |  | 
|   709  public: |   733  public: | 
|   710   SetCookieWithOptionsTask(CookieMonster* cookie_monster, |   734   SetCookieWithOptionsTask(CookieMonster* cookie_monster, | 
|   711                            const GURL& url, |   735                            const GURL& url, | 
|   712                            const std::string& cookie_line, |   736                            const std::string& cookie_line, | 
|   713                            const CookieOptions& options, |   737                            const CookieOptions& options, | 
|   714                            const CookieMonster::SetCookiesCallback& callback) |   738                            const SetCookiesCallback& callback) | 
|   715       : CookieMonsterTask(cookie_monster), |   739       : CookieMonsterTask(cookie_monster), | 
|   716         url_(url), |   740         url_(url), | 
|   717         cookie_line_(cookie_line), |   741         cookie_line_(cookie_line), | 
|   718         options_(options), |   742         options_(options), | 
|   719         callback_(callback) { |   743         callback_(callback) { | 
|   720   } |   744   } | 
|   721  |   745  | 
|   722   // CookieMonster::CookieMonsterTask: |   746   // CookieMonsterTask: | 
|   723   virtual void Run() OVERRIDE; |   747   virtual void Run() OVERRIDE; | 
|   724  |   748  | 
|   725  protected: |   749  protected: | 
|   726   virtual ~SetCookieWithOptionsTask() {} |   750   virtual ~SetCookieWithOptionsTask() {} | 
|   727  |   751  | 
|   728  private: |   752  private: | 
|   729   GURL url_; |   753   GURL url_; | 
|   730   std::string cookie_line_; |   754   std::string cookie_line_; | 
|   731   CookieOptions options_; |   755   CookieOptions options_; | 
|   732   CookieMonster::SetCookiesCallback callback_; |   756   SetCookiesCallback callback_; | 
|   733  |   757  | 
|   734   DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); |   758   DISALLOW_COPY_AND_ASSIGN(SetCookieWithOptionsTask); | 
|   735 }; |   759 }; | 
|   736  |   760  | 
|   737 void CookieMonster::SetCookieWithOptionsTask::Run() { |   761 void CookieMonster::SetCookieWithOptionsTask::Run() { | 
|   738   bool result = this->cookie_monster()-> |   762   bool result = this->cookie_monster()-> | 
|   739       SetCookieWithOptions(url_, cookie_line_, options_); |   763       SetCookieWithOptions(url_, cookie_line_, options_); | 
|   740   if (!callback_.is_null()) { |   764   if (!callback_.is_null()) { | 
|   741     this->InvokeCallback(base::Bind(&CookieMonster::SetCookiesCallback::Run, |   765     this->InvokeCallback(base::Bind(&SetCookiesCallback::Run, | 
|   742                                     base::Unretained(&callback_), result)); |   766                                     base::Unretained(&callback_), result)); | 
|   743   } |   767   } | 
|   744 } |   768 } | 
|   745  |   769  | 
|   746 // Task class for GetCookiesWithOptions call. |   770 // Task class for GetCookiesWithOptions call. | 
|   747 class CookieMonster::GetCookiesWithOptionsTask |   771 class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask { | 
|   748     : public CookieMonster::CookieMonsterTask { |  | 
|   749  public: |   772  public: | 
|   750   GetCookiesWithOptionsTask(CookieMonster* cookie_monster, |   773   GetCookiesWithOptionsTask(CookieMonster* cookie_monster, | 
|   751                             const GURL& url, |   774                             const GURL& url, | 
|   752                             const CookieOptions& options, |   775                             const CookieOptions& options, | 
|   753                             const CookieMonster::GetCookiesCallback& callback) |   776                             const GetCookiesCallback& callback) | 
|   754       : CookieMonsterTask(cookie_monster), |   777       : CookieMonsterTask(cookie_monster), | 
|   755         url_(url), |   778         url_(url), | 
|   756         options_(options), |   779         options_(options), | 
|   757         callback_(callback) { |   780         callback_(callback) { | 
|   758   } |   781   } | 
|   759  |   782  | 
|   760   // CookieMonster::CookieMonsterTask: |   783   // CookieMonsterTask: | 
|   761   virtual void Run() OVERRIDE; |   784   virtual void Run() OVERRIDE; | 
|   762  |   785  | 
|   763  protected: |   786  protected: | 
|   764   virtual ~GetCookiesWithOptionsTask() {} |   787   virtual ~GetCookiesWithOptionsTask() {} | 
|   765  |   788  | 
|   766  private: |   789  private: | 
|   767   GURL url_; |   790   GURL url_; | 
|   768   CookieOptions options_; |   791   CookieOptions options_; | 
|   769   CookieMonster::GetCookiesCallback callback_; |   792   GetCookiesCallback callback_; | 
|   770  |   793  | 
|   771   DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); |   794   DISALLOW_COPY_AND_ASSIGN(GetCookiesWithOptionsTask); | 
|   772 }; |   795 }; | 
|   773  |   796  | 
|   774 void CookieMonster::GetCookiesWithOptionsTask::Run() { |   797 void CookieMonster::GetCookiesWithOptionsTask::Run() { | 
|   775   std::string cookie = this->cookie_monster()-> |   798   std::string cookie = this->cookie_monster()-> | 
|   776       GetCookiesWithOptions(url_, options_); |   799       GetCookiesWithOptions(url_, options_); | 
|   777   if (!callback_.is_null()) { |   800   if (!callback_.is_null()) { | 
|   778     this->InvokeCallback(base::Bind(&CookieMonster::GetCookiesCallback::Run, |   801     this->InvokeCallback(base::Bind(&GetCookiesCallback::Run, | 
|   779                                     base::Unretained(&callback_), cookie)); |   802                                     base::Unretained(&callback_), cookie)); | 
|   780   } |   803   } | 
|   781 } |   804 } | 
|   782  |   805  | 
|   783 // Task class for DeleteCookie call. |   806 // Task class for DeleteCookie call. | 
|   784 class CookieMonster::DeleteCookieTask |   807 class CookieMonster::DeleteCookieTask : public DeleteTask<void> { | 
|   785     : public CookieMonster::CookieMonsterTask { |  | 
|   786  public: |   808  public: | 
|   787   DeleteCookieTask(CookieMonster* cookie_monster, |   809   DeleteCookieTask(CookieMonster* cookie_monster, | 
|   788                    const GURL& url, |   810                    const GURL& url, | 
|   789                    const std::string& cookie_name, |   811                    const std::string& cookie_name, | 
|   790                    const base::Closure& callback) |   812                    const base::Closure& callback) | 
|   791       : CookieMonsterTask(cookie_monster), |   813       : DeleteTask(cookie_monster, callback), | 
|   792         url_(url), |   814         url_(url), | 
|   793         cookie_name_(cookie_name), |   815         cookie_name_(cookie_name) { | 
|   794         callback_(callback) { } |   816   } | 
|   795  |   817  | 
|   796   // CookieMonster::CookieMonsterTask: |   818   // DeleteTask: | 
|   797   virtual void Run() OVERRIDE; |   819   virtual void RunDeleteTask() OVERRIDE; | 
|   798  |   820  | 
|   799  protected: |   821  protected: | 
|   800   virtual ~DeleteCookieTask() {} |   822   virtual ~DeleteCookieTask() {} | 
|   801  |   823  | 
|   802  private: |   824  private: | 
|   803   GURL url_; |   825   GURL url_; | 
|   804   std::string cookie_name_; |   826   std::string cookie_name_; | 
|   805   base::Closure callback_; |  | 
|   806  |   827  | 
|   807   DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); |   828   DISALLOW_COPY_AND_ASSIGN(DeleteCookieTask); | 
|   808 }; |   829 }; | 
|   809  |   830  | 
|   810 void CookieMonster::DeleteCookieTask::Run() { |   831 void CookieMonster::DeleteCookieTask::RunDeleteTask() { | 
|   811   this->cookie_monster()->DeleteCookie(url_, cookie_name_); |   832   this->cookie_monster()->DeleteCookie(url_, cookie_name_); | 
|   812   if (!callback_.is_null()) { |  | 
|   813     this->InvokeCallback(callback_); |  | 
|   814   } |  | 
|   815 } |   833 } | 
|   816  |   834  | 
|   817 // Task class for DeleteSessionCookies call. |   835 // Task class for DeleteSessionCookies call. | 
|   818 class CookieMonster::DeleteSessionCookiesTask |   836 class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> { | 
|   819     : public CookieMonster::CookieMonsterTask { |  | 
|   820  public: |   837  public: | 
|   821   DeleteSessionCookiesTask(CookieMonster* cookie_monster, |   838   DeleteSessionCookiesTask(CookieMonster* cookie_monster, | 
|   822                            const CookieMonster::DeleteCallback& callback) |   839                            const DeleteCallback& callback) | 
|   823       : CookieMonsterTask(cookie_monster), callback_(callback) { |   840       : DeleteTask(cookie_monster, callback) { | 
|   824   } |   841   } | 
|   825  |   842  | 
|   826   // CookieMonster::CookieMonsterTask: |   843   // DeleteTask: | 
|   827   virtual void Run() OVERRIDE; |   844   virtual int RunDeleteTask() OVERRIDE; | 
|   828  |   845  | 
|   829  protected: |   846  protected: | 
|   830   virtual ~DeleteSessionCookiesTask() {} |   847   virtual ~DeleteSessionCookiesTask() {} | 
|   831  |   848  | 
|   832  private: |   849  private: | 
|   833   CookieMonster::DeleteCallback callback_; |  | 
|   834  |   850  | 
|   835   DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); |   851   DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask); | 
|   836 }; |   852 }; | 
|   837  |   853  | 
|   838 void CookieMonster::DeleteSessionCookiesTask::Run() { |   854 int CookieMonster::DeleteSessionCookiesTask::RunDeleteTask() { | 
|   839   int num_deleted = this->cookie_monster()->DeleteSessionCookies(); |   855   return this->cookie_monster()->DeleteSessionCookies(); | 
|   840   if (!callback_.is_null()) { |  | 
|   841     this->InvokeCallback(base::Bind(&CookieMonster::DeleteCallback::Run, |  | 
|   842                                     base::Unretained(&callback_), num_deleted)); |  | 
|   843   } |  | 
|   844 } |   856 } | 
|   845  |   857  | 
|   846 // Task class for HasCookiesForETLDP1Task call. |   858 // Task class for HasCookiesForETLDP1Task call. | 
|   847 class CookieMonster::HasCookiesForETLDP1Task |   859 class CookieMonster::HasCookiesForETLDP1Task : public CookieMonsterTask { | 
|   848     : public CookieMonster::CookieMonsterTask { |  | 
|   849  public: |   860  public: | 
|   850   HasCookiesForETLDP1Task( |   861   HasCookiesForETLDP1Task( | 
|   851       CookieMonster* cookie_monster, |   862       CookieMonster* cookie_monster, | 
|   852       const std::string& etldp1, |   863       const std::string& etldp1, | 
|   853       const CookieMonster::HasCookiesForETLDP1Callback& callback) |   864       const HasCookiesForETLDP1Callback& callback) | 
|   854       : CookieMonsterTask(cookie_monster), |   865       : CookieMonsterTask(cookie_monster), | 
|   855         etldp1_(etldp1), |   866         etldp1_(etldp1), | 
|   856         callback_(callback) { |   867         callback_(callback) { | 
|   857   } |   868   } | 
|   858  |   869  | 
|   859   // CookieMonster::CookieMonsterTask: |   870   // CookieMonsterTask: | 
|   860   virtual void Run() OVERRIDE; |   871   virtual void Run() OVERRIDE; | 
|   861  |   872  | 
|   862  protected: |   873  protected: | 
|   863   virtual ~HasCookiesForETLDP1Task() {} |   874   virtual ~HasCookiesForETLDP1Task() {} | 
|   864  |   875  | 
|   865  private: |   876  private: | 
|   866   std::string etldp1_; |   877   std::string etldp1_; | 
|   867   CookieMonster::HasCookiesForETLDP1Callback callback_; |   878   HasCookiesForETLDP1Callback callback_; | 
|   868  |   879  | 
|   869   DISALLOW_COPY_AND_ASSIGN(HasCookiesForETLDP1Task); |   880   DISALLOW_COPY_AND_ASSIGN(HasCookiesForETLDP1Task); | 
|   870 }; |   881 }; | 
|   871  |   882  | 
|   872 void CookieMonster::HasCookiesForETLDP1Task::Run() { |   883 void CookieMonster::HasCookiesForETLDP1Task::Run() { | 
|   873   bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_); |   884   bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_); | 
|   874   if (!callback_.is_null()) { |   885   if (!callback_.is_null()) { | 
|   875     this->InvokeCallback( |   886     this->InvokeCallback( | 
|   876         base::Bind(&CookieMonster::HasCookiesForETLDP1Callback::Run, |   887         base::Bind(&HasCookiesForETLDP1Callback::Run, | 
|   877                    base::Unretained(&callback_), result)); |   888                    base::Unretained(&callback_), result)); | 
|   878   } |   889   } | 
|   879 } |   890 } | 
|   880  |   891  | 
|   881 // Asynchronous CookieMonster API |   892 // Asynchronous CookieMonster API | 
|   882  |   893  | 
|   883 void CookieMonster::SetCookieWithDetailsAsync( |   894 void CookieMonster::SetCookieWithDetailsAsync( | 
|   884     const GURL& url, |   895     const GURL& url, | 
|   885     const std::string& name, |   896     const std::string& name, | 
|   886     const std::string& value, |   897     const std::string& value, | 
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1632   } |  1643   } | 
|  1633   DCHECK_EQ(num_duplicates, num_duplicates_found); |  1644   DCHECK_EQ(num_duplicates, num_duplicates_found); | 
|  1634  |  1645  | 
|  1635   return num_duplicates; |  1646   return num_duplicates; | 
|  1636 } |  1647 } | 
|  1637  |  1648  | 
|  1638 // Note: file must be the last scheme. |  1649 // Note: file must be the last scheme. | 
|  1639 const char* CookieMonster::kDefaultCookieableSchemes[] = |  1650 const char* CookieMonster::kDefaultCookieableSchemes[] = | 
|  1640     { "http", "https", "file" }; |  1651     { "http", "https", "file" }; | 
|  1641 const int CookieMonster::kDefaultCookieableSchemesCount = |  1652 const int CookieMonster::kDefaultCookieableSchemesCount = | 
|  1642     arraysize(CookieMonster::kDefaultCookieableSchemes); |  1653     arraysize(kDefaultCookieableSchemes); | 
|  1643  |  1654  | 
|  1644 void CookieMonster::SetDefaultCookieableSchemes() { |  1655 void CookieMonster::SetDefaultCookieableSchemes() { | 
|  1645   int num_schemes = default_enable_file_scheme_ ? |  1656   int num_schemes = default_enable_file_scheme_ ? | 
|  1646       kDefaultCookieableSchemesCount : kDefaultCookieableSchemesCount - 1; |  1657       kDefaultCookieableSchemesCount : kDefaultCookieableSchemesCount - 1; | 
|  1647   SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes); |  1658   SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes); | 
|  1648 } |  1659 } | 
|  1649  |  1660  | 
|  1650 void CookieMonster::FindCookiesForHostAndDomain( |  1661 void CookieMonster::FindCookiesForHostAndDomain( | 
|  1651     const GURL& url, |  1662     const GURL& url, | 
|  1652     const CookieOptions& options, |  1663     const CookieOptions& options, | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1737                                          CanonicalCookie* cc, |  1748                                          CanonicalCookie* cc, | 
|  1738                                          bool sync_to_store) { |  1749                                          bool sync_to_store) { | 
|  1739   lock_.AssertAcquired(); |  1750   lock_.AssertAcquired(); | 
|  1740  |  1751  | 
|  1741   if ((cc->IsPersistent() || persist_session_cookies_) && store_.get() && |  1752   if ((cc->IsPersistent() || persist_session_cookies_) && store_.get() && | 
|  1742       sync_to_store) |  1753       sync_to_store) | 
|  1743     store_->AddCookie(*cc); |  1754     store_->AddCookie(*cc); | 
|  1744   cookies_.insert(CookieMap::value_type(key, cc)); |  1755   cookies_.insert(CookieMap::value_type(key, cc)); | 
|  1745   if (delegate_.get()) { |  1756   if (delegate_.get()) { | 
|  1746     delegate_->OnCookieChanged( |  1757     delegate_->OnCookieChanged( | 
|  1747         *cc, false, CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT); |  1758         *cc, false, Delegate::CHANGE_COOKIE_EXPLICIT); | 
|  1748   } |  1759   } | 
|  1749 } |  1760 } | 
|  1750  |  1761  | 
|  1751 bool CookieMonster::SetCookieWithCreationTimeAndOptions( |  1762 bool CookieMonster::SetCookieWithCreationTimeAndOptions( | 
|  1752     const GURL& url, |  1763     const GURL& url, | 
|  1753     const std::string& cookie_line, |  1764     const std::string& cookie_line, | 
|  1754     const Time& creation_time_or_null, |  1765     const Time& creation_time_or_null, | 
|  1755     const CookieOptions& options) { |  1766     const CookieOptions& options) { | 
|  1756   lock_.AssertAcquired(); |  1767   lock_.AssertAcquired(); | 
|  1757  |  1768  | 
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2008       cookie_its->push_back(curit); |  2019       cookie_its->push_back(curit); | 
|  2009     } |  2020     } | 
|  2010   } |  2021   } | 
|  2011  |  2022  | 
|  2012   return num_deleted; |  2023   return num_deleted; | 
|  2013 } |  2024 } | 
|  2014  |  2025  | 
|  2015 int CookieMonster::GarbageCollectDeleteRange( |  2026 int CookieMonster::GarbageCollectDeleteRange( | 
|  2016     const Time& current, |  2027     const Time& current, | 
|  2017     DeletionCause cause, |  2028     DeletionCause cause, | 
|  2018     CookieMonster::CookieItVector::iterator it_begin, |  2029     CookieItVector::iterator it_begin, | 
|  2019     CookieMonster::CookieItVector::iterator it_end) { |  2030     CookieItVector::iterator it_end) { | 
|  2020   for (CookieItVector::iterator it = it_begin; it != it_end; it++) { |  2031   for (CookieItVector::iterator it = it_begin; it != it_end; it++) { | 
|  2021     histogram_evicted_last_access_minutes_->Add( |  2032     histogram_evicted_last_access_minutes_->Add( | 
|  2022         (current - (*it)->second->LastAccessDate()).InMinutes()); |  2033         (current - (*it)->second->LastAccessDate()).InMinutes()); | 
|  2023     InternalDeleteCookie((*it), true, cause); |  2034     InternalDeleteCookie((*it), true, cause); | 
|  2024   } |  2035   } | 
|  2025   return it_end - it_begin; |  2036   return it_end - it_begin; | 
|  2026 } |  2037 } | 
|  2027  |  2038  | 
|  2028 // A wrapper around registry_controlled_domains::GetDomainAndRegistry |  2039 // A wrapper around registry_controlled_domains::GetDomainAndRegistry | 
|  2029 // to make clear we're creating a key for our local map.  Here and |  2040 // to make clear we're creating a key for our local map.  Here and | 
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2214  |  2225  | 
|  2215 // The system resolution is not high enough, so we can have multiple |  2226 // The system resolution is not high enough, so we can have multiple | 
|  2216 // set cookies that result in the same system time.  When this happens, we |  2227 // set cookies that result in the same system time.  When this happens, we | 
|  2217 // increment by one Time unit.  Let's hope computers don't get too fast. |  2228 // increment by one Time unit.  Let's hope computers don't get too fast. | 
|  2218 Time CookieMonster::CurrentTime() { |  2229 Time CookieMonster::CurrentTime() { | 
|  2219   return std::max(Time::Now(), |  2230   return std::max(Time::Now(), | 
|  2220       Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); |  2231       Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1)); | 
|  2221 } |  2232 } | 
|  2222  |  2233  | 
|  2223 }  // namespace net |  2234 }  // namespace net | 
| OLD | NEW |