Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: net/extras/sqlite/sqlite_persistent_cookie_store.cc

Issue 1016643004: Moves SQLitePersistentCookieStore to net/extras/sqlite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cookies
Patch Set: Maybe fix bots. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/extras/sqlite/sqlite_persistent_cookie_store.cc
diff --git a/content/browser/net/sqlite_persistent_cookie_store.cc b/net/extras/sqlite/sqlite_persistent_cookie_store.cc
similarity index 86%
rename from content/browser/net/sqlite_persistent_cookie_store.cc
rename to net/extras/sqlite/sqlite_persistent_cookie_store.cc
index 6b2ff26ec3703f05d83b3d892ac16b6468a35700..b8cfe7c64e4baaf8b6652ee6d6eb7c7149042f63 100644
--- a/content/browser/net/sqlite_persistent_cookie_store.cc
+++ b/net/extras/sqlite/sqlite_persistent_cookie_store.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/net/sqlite_persistent_cookie_store.h"
+#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include <list>
#include <map>
@@ -27,8 +27,6 @@
#include "base/synchronization/lock.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
@@ -38,8 +36,6 @@
#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"
-#include "storage/browser/quota/special_storage_policy.h"
-#include "third_party/sqlite/sqlite3.h"
#include "url/gurl.h"
using base::Time;
@@ -53,7 +49,7 @@ const int kLoadDelayMilliseconds = 0;
} // namespace
-namespace content {
+namespace net {
// This class is designed to be shared between any client thread and the
// background task runner. It batches operations and commits them on a timer.
@@ -85,15 +81,12 @@ class SQLitePersistentCookieStore::Backend
const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
bool restore_old_session_cookies,
- storage::SpecialStoragePolicy* special_storage_policy,
- net::CookieCryptoDelegate* crypto_delegate)
+ CookieCryptoDelegate* crypto_delegate)
: path_(path),
num_pending_(0),
- force_keep_session_state_(false),
initialized_(false),
corruption_detected_(false),
restore_old_session_cookies_(restore_old_session_cookies),
- special_storage_policy_(special_storage_policy),
num_cookies_read_(0),
client_task_runner_(client_task_runner),
background_task_runner_(background_task_runner),
@@ -109,19 +102,18 @@ class SQLitePersistentCookieStore::Backend
const LoadedCallback& loaded_callback);
// Steps through all results of |smt|, makes a cookie from each, and adds the
- // cookie to |cookies|. This method also updates |cookies_per_origin_| and
- // |num_cookies_read_|.
- void MakeCookiesFromSQLStatement(std::vector<net::CanonicalCookie*>* cookies,
+ // cookie to |cookies|. This method also updates |num_cookies_read_|.
+ void MakeCookiesFromSQLStatement(std::vector<CanonicalCookie*>* cookies,
sql::Statement* statement);
// Batch a cookie addition.
- void AddCookie(const net::CanonicalCookie& cc);
+ void AddCookie(const CanonicalCookie& cc);
// Batch a cookie access time update.
- void UpdateCookieAccessTime(const net::CanonicalCookie& cc);
+ void UpdateCookieAccessTime(const CanonicalCookie& cc);
// Batch a cookie deletion.
- void DeleteCookie(const net::CanonicalCookie& cc);
+ void DeleteCookie(const CanonicalCookie& cc);
// Commit pending operations as soon as possible.
void Flush(const base::Closure& callback);
@@ -130,7 +122,8 @@ class SQLitePersistentCookieStore::Backend
// before the object is destructed.
void Close();
- void SetForceKeepSessionState();
+ // Post background delete of all cookies that match |cookies|.
+ void DeleteAllInList(const std::list<CookieOrigin>& cookies);
private:
friend class base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend>;
@@ -138,9 +131,10 @@ class SQLitePersistentCookieStore::Backend
// You should call Close() before destructing this object.
~Backend() {
DCHECK(!db_.get()) << "Close should have already been called.";
- DCHECK(num_pending_ == 0 && pending_.empty());
+ DCHECK_EQ(0u, num_pending_);
+ DCHECK(pending_.empty());
- for (net::CanonicalCookie* cookie : cookies_) {
+ for (CanonicalCookie* cookie : cookies_) {
delete cookie;
}
}
@@ -150,21 +144,21 @@ class SQLitePersistentCookieStore::Backend
class PendingOperation {
public:
- typedef enum {
+ enum OperationType {
COOKIE_ADD,
COOKIE_UPDATEACCESS,
COOKIE_DELETE,
- } OperationType;
+ };
- PendingOperation(OperationType op, const net::CanonicalCookie& cc)
+ PendingOperation(OperationType op, const CanonicalCookie& cc)
: op_(op), cc_(cc) { }
OperationType op() const { return op_; }
- const net::CanonicalCookie& cc() const { return cc_; }
+ const CanonicalCookie& cc() const { return cc_; }
private:
OperationType op_;
- net::CanonicalCookie cc_;
+ CanonicalCookie cc_;
};
private:
@@ -215,7 +209,7 @@ class SQLitePersistentCookieStore::Backend
// Batch a cookie operation (add or delete)
void BatchOperation(PendingOperation::OperationType op,
- const net::CanonicalCookie& cc);
+ const CanonicalCookie& cc);
// Commit our pending operations to the database.
void Commit();
// Close() executed on the background runner.
@@ -223,7 +217,7 @@ class SQLitePersistentCookieStore::Backend
void DeleteSessionCookiesOnStartup();
- void DeleteSessionCookiesOnShutdown();
+ void BackgroundDeleteAllInList(const std::list<CookieOrigin>& cookies);
void DatabaseErrorCallback(int error, sql::Statement* stmt);
void KillDatabase();
@@ -238,16 +232,14 @@ class SQLitePersistentCookieStore::Backend
void FinishedLoadingCookies(const LoadedCallback& loaded_callback,
bool success);
- base::FilePath path_;
+ const base::FilePath path_;
scoped_ptr<sql::Connection> db_;
sql::MetaTable meta_table_;
typedef std::list<PendingOperation*> PendingOperationsList;
PendingOperationsList pending_;
PendingOperationsList::size_type num_pending_;
- // True if the persistent store should skip delete on exit rules.
- bool force_keep_session_state_;
- // Guard |cookies_|, |pending_|, |num_pending_|, |force_keep_session_state_|
+ // Guard |cookies_|, |pending_|, |num_pending_|.
base::Lock lock_;
// Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce
@@ -255,17 +247,11 @@ class SQLitePersistentCookieStore::Backend
// individual load requests for domain keys or when all loading completes.
// Ownership of the cookies in this vector is transferred to the client in
// response to individual load requests or when all loading completes.
- std::vector<net::CanonicalCookie*> cookies_;
+ std::vector<CanonicalCookie*> cookies_;
// Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB.
std::map<std::string, std::set<std::string> > keys_to_load_;
- // Map of (domain keys(eTLD+1), is secure cookie) to number of cookies in the
- // database.
- typedef std::pair<std::string, bool> CookieOrigin;
- typedef std::map<CookieOrigin, int> CookiesPerOriginMap;
- CookiesPerOriginMap cookies_per_origin_;
-
// Indicates if DB has been initialized.
bool initialized_;
@@ -275,9 +261,6 @@ class SQLitePersistentCookieStore::Backend
// If false, we should filter out session cookies when reading the DB.
bool restore_old_session_cookies_;
- // Policy defining what data is deleted on shutdown.
- scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
-
// The cumulative time spent loading the cookies on the background runner.
// Incremented and reported from the background runner.
base::TimeDelta cookie_load_duration_;
@@ -304,7 +287,7 @@ class SQLitePersistentCookieStore::Backend
// cookies stored persistently).
//
// Not owned.
- net::CookieCryptoDelegate* crypto_;
+ CookieCryptoDelegate* crypto_;
DISALLOW_COPY_AND_ASSIGN(Backend);
};
@@ -353,13 +336,13 @@ enum DBCookiePriority {
kCookiePriorityHigh = 2,
};
-DBCookiePriority CookiePriorityToDBCookiePriority(net::CookiePriority value) {
+DBCookiePriority CookiePriorityToDBCookiePriority(CookiePriority value) {
switch (value) {
- case net::COOKIE_PRIORITY_LOW:
+ case COOKIE_PRIORITY_LOW:
return kCookiePriorityLow;
- case net::COOKIE_PRIORITY_MEDIUM:
+ case COOKIE_PRIORITY_MEDIUM:
return kCookiePriorityMedium;
- case net::COOKIE_PRIORITY_HIGH:
+ case COOKIE_PRIORITY_HIGH:
return kCookiePriorityHigh;
}
@@ -367,18 +350,18 @@ DBCookiePriority CookiePriorityToDBCookiePriority(net::CookiePriority value) {
return kCookiePriorityMedium;
}
-net::CookiePriority DBCookiePriorityToCookiePriority(DBCookiePriority value) {
+CookiePriority DBCookiePriorityToCookiePriority(DBCookiePriority value) {
switch (value) {
case kCookiePriorityLow:
- return net::COOKIE_PRIORITY_LOW;
+ return COOKIE_PRIORITY_LOW;
case kCookiePriorityMedium:
- return net::COOKIE_PRIORITY_MEDIUM;
+ return COOKIE_PRIORITY_MEDIUM;
case kCookiePriorityHigh:
- return net::COOKIE_PRIORITY_HIGH;
+ return COOKIE_PRIORITY_HIGH;
}
NOTREACHED();
- return net::COOKIE_PRIORITY_DEFAULT;
+ return COOKIE_PRIORITY_DEFAULT;
}
// Increments a specified TimeDelta by the duration between this object's
@@ -425,7 +408,7 @@ bool InitTable(sql::Connection* db) {
"priority INTEGER NOT NULL DEFAULT %d,"
"encrypted_value BLOB DEFAULT '',"
"firstpartyonly INTEGER NOT NULL DEFAULT 0)",
- CookiePriorityToDBCookiePriority(net::COOKIE_PRIORITY_DEFAULT)));
+ CookiePriorityToDBCookiePriority(COOKIE_PRIORITY_DEFAULT)));
if (!db->Execute(stmt.c_str()))
return false;
@@ -589,7 +572,7 @@ void SQLitePersistentCookieStore::Backend::Notify(
bool load_success) {
DCHECK(client_task_runner_->RunsTasksOnCurrentThread());
- std::vector<net::CanonicalCookie*> cookies;
+ std::vector<CanonicalCookie*> cookies;
{
base::AutoLock locked(lock_);
cookies.swap(cookies_);
@@ -680,9 +663,9 @@ bool SQLitePersistentCookieStore::Backend::InitializeDatabase() {
for (size_t idx = 0; idx < host_keys.size(); ++idx) {
const std::string& domain = host_keys[idx];
std::string key =
- net::registry_controlled_domains::GetDomainAndRegistry(
+ registry_controlled_domains::GetDomainAndRegistry(
domain,
- net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
+ registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
keys_to_load_[key].insert(domain);
}
@@ -767,7 +750,7 @@ bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains(
return false;
}
- std::vector<net::CanonicalCookie*> cookies;
+ std::vector<CanonicalCookie*> cookies;
std::set<std::string>::const_iterator it = domains.begin();
for (; it != domains.end(); ++it) {
smt.BindString(0, *it);
@@ -782,7 +765,7 @@ bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains(
}
void SQLitePersistentCookieStore::Backend::MakeCookiesFromSQLStatement(
- std::vector<net::CanonicalCookie*>* cookies,
+ std::vector<CanonicalCookie*>* cookies,
sql::Statement* statement) {
sql::Statement& smt = *statement;
while (smt.Step()) {
@@ -794,7 +777,7 @@ void SQLitePersistentCookieStore::Backend::MakeCookiesFromSQLStatement(
DCHECK(encrypted_value.empty());
value = smt.ColumnString(3);
}
- scoped_ptr<net::CanonicalCookie> cc(new net::CanonicalCookie(
+ scoped_ptr<CanonicalCookie> cc(new CanonicalCookie(
// The "source" URL is not used with persisted cookies.
GURL(), // Source
smt.ColumnString(2), // name
@@ -811,7 +794,6 @@ void SQLitePersistentCookieStore::Backend::MakeCookiesFromSQLStatement(
static_cast<DBCookiePriority>(smt.ColumnInt(13))))); // priority
DLOG_IF(WARNING, cc->CreationDate() > Time::Now())
<< L"CreationDate too recent";
- cookies_per_origin_[CookieOrigin(cc->Domain(), cc->IsSecure())]++;
cookies->push_back(cc.release());
++num_cookies_read_;
}
@@ -910,7 +892,7 @@ bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() {
// Alter the table to add the priority column with a default value.
std::string stmt(base::StringPrintf(
"ALTER TABLE cookies ADD COLUMN priority INTEGER DEFAULT %d",
- CookiePriorityToDBCookiePriority(net::COOKIE_PRIORITY_DEFAULT)));
+ CookiePriorityToDBCookiePriority(COOKIE_PRIORITY_DEFAULT)));
if (!db_->Execute(stmt.c_str())) {
LOG(WARNING) << "Unable to update cookie database to version 6.";
return false;
@@ -1029,23 +1011,23 @@ bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() {
}
void SQLitePersistentCookieStore::Backend::AddCookie(
- const net::CanonicalCookie& cc) {
+ const CanonicalCookie& cc) {
BatchOperation(PendingOperation::COOKIE_ADD, cc);
}
void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime(
- const net::CanonicalCookie& cc) {
+ const CanonicalCookie& cc) {
BatchOperation(PendingOperation::COOKIE_UPDATEACCESS, cc);
}
void SQLitePersistentCookieStore::Backend::DeleteCookie(
- const net::CanonicalCookie& cc) {
+ const CanonicalCookie& cc) {
BatchOperation(PendingOperation::COOKIE_DELETE, cc);
}
void SQLitePersistentCookieStore::Backend::BatchOperation(
PendingOperation::OperationType op,
- const net::CanonicalCookie& cc) {
+ const CanonicalCookie& cc) {
// Commit every 30 seconds.
static const int kCommitIntervalMs = 30 * 1000;
// Commit right away if we have more than 512 outstanding operations.
@@ -1118,8 +1100,6 @@ void SQLitePersistentCookieStore::Backend::Commit() {
scoped_ptr<PendingOperation> po(*it);
switch (po->op()) {
case PendingOperation::COOKIE_ADD:
- cookies_per_origin_[
- CookieOrigin(po->cc().Domain(), po->cc().IsSecure())]++;
add_smt.Reset(true);
add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue());
add_smt.BindString(1, po->cc().Domain());
@@ -1160,8 +1140,6 @@ void SQLitePersistentCookieStore::Backend::Commit() {
break;
case PendingOperation::COOKIE_DELETE:
- cookies_per_origin_[
- CookieOrigin(po->cc().Domain(), po->cc().IsSecure())]--;
del_smt.Reset(true);
del_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue());
if (!del_smt.Run())
@@ -1209,59 +1187,10 @@ void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() {
// Commit any pending operations
Commit();
- if (!force_keep_session_state_ && special_storage_policy_.get() &&
- special_storage_policy_->HasSessionOnlyOrigins()) {
- DeleteSessionCookiesOnShutdown();
- }
-
meta_table_.Reset();
db_.reset();
}
-void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() {
- DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
-
- if (!db_)
- return;
-
- if (!special_storage_policy_.get())
- return;
-
- sql::Statement del_smt(db_->GetCachedStatement(
- SQL_FROM_HERE, "DELETE FROM cookies WHERE host_key=? AND secure=?"));
- if (!del_smt.is_valid()) {
- LOG(WARNING) << "Unable to delete cookies on shutdown.";
- return;
- }
-
- sql::Transaction transaction(db_.get());
- if (!transaction.Begin()) {
- LOG(WARNING) << "Unable to delete cookies on shutdown.";
- return;
- }
-
- for (CookiesPerOriginMap::iterator it = cookies_per_origin_.begin();
- it != cookies_per_origin_.end(); ++it) {
- if (it->second <= 0) {
- DCHECK_EQ(0, it->second);
- continue;
- }
- const GURL url(net::cookie_util::CookieOriginToURL(it->first.first,
- it->first.second));
- if (!url.is_valid() || !special_storage_policy_->IsStorageSessionOnly(url))
- continue;
-
- del_smt.Reset(true);
- del_smt.BindString(0, it->first.first);
- del_smt.BindInt(1, it->first.second);
- if (!del_smt.Run())
- NOTREACHED() << "Could not delete a cookie from the DB.";
- }
-
- if (!transaction.Commit())
- LOG(WARNING) << "Unable to delete cookies on shutdown.";
-}
-
void SQLitePersistentCookieStore::Backend::DatabaseErrorCallback(
int error,
sql::Statement* stmt) {
@@ -1298,9 +1227,16 @@ void SQLitePersistentCookieStore::Backend::KillDatabase() {
}
}
-void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() {
- base::AutoLock locked(lock_);
- force_keep_session_state_ = true;
+void SQLitePersistentCookieStore::Backend::DeleteAllInList(
+ const std::list<CookieOrigin>& cookies) {
+ if (cookies.empty())
+ return;
+
+ // Perform deletion on background task runner.
+ background_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &Backend::BackgroundDeleteAllInList, this, cookies));
}
void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
@@ -1309,6 +1245,47 @@ void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
LOG(WARNING) << "Unable to delete session cookies.";
}
+void SQLitePersistentCookieStore::Backend::BackgroundDeleteAllInList(
+ const std::list<CookieOrigin>& cookies) {
+ DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
+
+ if (!db_)
+ return;
+
+ // Force a commit of any pending writes before issuing deletes.
+ // TODO(rohitrao): Remove the need for this Commit() by instead pruning the
+ // list of pending operations. https://crbug.com/486742.
+ Commit();
+
+ sql::Statement del_smt(db_->GetCachedStatement(
+ SQL_FROM_HERE, "DELETE FROM cookies WHERE host_key=? AND secure=?"));
+ if (!del_smt.is_valid()) {
+ LOG(WARNING) << "Unable to delete cookies on shutdown.";
+ return;
+ }
+
+ sql::Transaction transaction(db_.get());
+ if (!transaction.Begin()) {
+ LOG(WARNING) << "Unable to delete cookies on shutdown.";
+ return;
+ }
+
+ for (const auto& cookie : cookies) {
+ const GURL url(cookie_util::CookieOriginToURL(cookie.first, cookie.second));
+ if (!url.is_valid())
+ continue;
+
+ del_smt.Reset(true);
+ del_smt.BindString(0, cookie.first);
+ del_smt.BindInt(1, cookie.second);
+ if (!del_smt.Run())
+ NOTREACHED() << "Could not delete a cookie from the DB.";
+ }
+
+ if (!transaction.Commit())
+ LOG(WARNING) << "Unable to delete cookies on shutdown.";
+}
+
void SQLitePersistentCookieStore::Backend::PostBackgroundTask(
const tracked_objects::Location& origin, const base::Closure& task) {
if (!background_task_runner_->PostTask(origin, task)) {
@@ -1337,16 +1314,19 @@ SQLitePersistentCookieStore::SQLitePersistentCookieStore(
const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
bool restore_old_session_cookies,
- storage::SpecialStoragePolicy* special_storage_policy,
- net::CookieCryptoDelegate* crypto_delegate)
+ CookieCryptoDelegate* crypto_delegate)
: backend_(new Backend(path,
client_task_runner,
background_task_runner,
restore_old_session_cookies,
- special_storage_policy,
crypto_delegate)) {
}
+void SQLitePersistentCookieStore::DeleteAllInList(
+ const std::list<CookieOrigin>& cookies) {
+ backend_->DeleteAllInList(cookies);
+}
+
void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
backend_->Load(loaded_callback);
}
@@ -1357,21 +1337,21 @@ void SQLitePersistentCookieStore::LoadCookiesForKey(
backend_->LoadCookiesForKey(key, loaded_callback);
}
-void SQLitePersistentCookieStore::AddCookie(const net::CanonicalCookie& cc) {
+void SQLitePersistentCookieStore::AddCookie(const CanonicalCookie& cc) {
backend_->AddCookie(cc);
}
void SQLitePersistentCookieStore::UpdateCookieAccessTime(
- const net::CanonicalCookie& cc) {
+ const CanonicalCookie& cc) {
backend_->UpdateCookieAccessTime(cc);
}
-void SQLitePersistentCookieStore::DeleteCookie(const net::CanonicalCookie& cc) {
+void SQLitePersistentCookieStore::DeleteCookie(const CanonicalCookie& cc) {
backend_->DeleteCookie(cc);
}
void SQLitePersistentCookieStore::SetForceKeepSessionState() {
- backend_->SetForceKeepSessionState();
+ // This store never discards session-only cookies, so this call has no effect.
}
void SQLitePersistentCookieStore::Flush(const base::Closure& callback) {
@@ -1384,76 +1364,4 @@ SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
// a reference if the background runner has not run Close() yet.
}
-CookieStoreConfig::CookieStoreConfig()
- : session_cookie_mode(EPHEMERAL_SESSION_COOKIES),
- crypto_delegate(NULL) {
- // Default to an in-memory cookie store.
-}
-
-CookieStoreConfig::CookieStoreConfig(
- const base::FilePath& path,
- SessionCookieMode session_cookie_mode,
- storage::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate)
- : path(path),
- session_cookie_mode(session_cookie_mode),
- storage_policy(storage_policy),
- cookie_delegate(cookie_delegate),
- crypto_delegate(NULL) {
- CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES);
-}
-
-CookieStoreConfig::~CookieStoreConfig() {
-}
-
-net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) {
- // TODO(bcwhite): Remove ScopedTracker below once crbug.com/483686 is fixed.
- tracked_objects::ScopedTracker tracking_profile(
- FROM_HERE_WITH_EXPLICIT_FUNCTION("483686 content::CreateCookieStore"));
-
- net::CookieMonster* cookie_monster = NULL;
-
- if (config.path.empty()) {
- // Empty path means in-memory store.
- cookie_monster = new net::CookieMonster(NULL, config.cookie_delegate.get());
- } else {
- scoped_refptr<base::SequencedTaskRunner> client_task_runner =
- config.client_task_runner;
- scoped_refptr<base::SequencedTaskRunner> background_task_runner =
- config.background_task_runner;
-
- if (!client_task_runner.get()) {
- client_task_runner =
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
- }
-
- if (!background_task_runner.get()) {
- background_task_runner =
- BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
- BrowserThread::GetBlockingPool()->GetSequenceToken());
- }
-
- SQLitePersistentCookieStore* persistent_store =
- new SQLitePersistentCookieStore(
- config.path,
- client_task_runner,
- background_task_runner,
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES),
- config.storage_policy.get(),
- config.crypto_delegate);
-
- cookie_monster =
- new net::CookieMonster(persistent_store, config.cookie_delegate.get());
- if ((config.session_cookie_mode ==
- CookieStoreConfig::PERSISTANT_SESSION_COOKIES) ||
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES)) {
- cookie_monster->SetPersistSessionCookies(true);
- }
- }
-
- return cookie_monster;
-}
-
-} // namespace content
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698