summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/sqlite_persistent_cookie_store.cc
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
committerIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
commit3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch)
tree7784b988ef1698cb6967ea1bdf07616237716c6c /chrome/browser/net/sqlite_persistent_cookie_store.cc
parentefc8475837ec58186051f23bb03542620424f6ce (diff)
downloadexternal_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used. Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'chrome/browser/net/sqlite_persistent_cookie_store.cc')
-rw-r--r--chrome/browser/net/sqlite_persistent_cookie_store.cc34
1 files changed, 12 insertions, 22 deletions
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc
index ec8eaf9..b0f932d 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc
@@ -10,6 +10,7 @@
#include "app/sql/transaction.h"
#include "base/basictypes.h"
#include "base/file_util.h"
+#include "base/histogram.h"
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
@@ -59,8 +60,7 @@ class SQLitePersistentCookieStore::Backend
}
// Batch a cookie addition.
- void AddCookie(const std::string& key,
- const net::CookieMonster::CanonicalCookie& cc);
+ void AddCookie(const net::CookieMonster::CanonicalCookie& cc);
// Batch a cookie access time update.
void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cc);
@@ -90,24 +90,20 @@ class SQLitePersistentCookieStore::Backend
} OperationType;
PendingOperation(OperationType op,
- const std::string& key,
const net::CookieMonster::CanonicalCookie& cc)
- : op_(op), key_(key), cc_(cc) { }
+ : op_(op), cc_(cc) { }
OperationType op() const { return op_; }
- const std::string& key() const { return key_; }
const net::CookieMonster::CanonicalCookie& cc() const { return cc_; }
private:
OperationType op_;
- std::string key_; // Only used for OP_ADD
net::CookieMonster::CanonicalCookie cc_;
};
private:
// Batch a cookie operation (add or delete)
void BatchOperation(PendingOperation::OperationType op,
- const std::string& key,
const net::CookieMonster::CanonicalCookie& cc);
// Commit our pending operations to the database.
void Commit();
@@ -125,24 +121,22 @@ class SQLitePersistentCookieStore::Backend
};
void SQLitePersistentCookieStore::Backend::AddCookie(
- const std::string& key,
const net::CookieMonster::CanonicalCookie& cc) {
- BatchOperation(PendingOperation::COOKIE_ADD, key, cc);
+ BatchOperation(PendingOperation::COOKIE_ADD, cc);
}
void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime(
const net::CookieMonster::CanonicalCookie& cc) {
- BatchOperation(PendingOperation::COOKIE_UPDATEACCESS, std::string(), cc);
+ BatchOperation(PendingOperation::COOKIE_UPDATEACCESS, cc);
}
void SQLitePersistentCookieStore::Backend::DeleteCookie(
const net::CookieMonster::CanonicalCookie& cc) {
- BatchOperation(PendingOperation::COOKIE_DELETE, std::string(), cc);
+ BatchOperation(PendingOperation::COOKIE_DELETE, cc);
}
void SQLitePersistentCookieStore::Backend::BatchOperation(
PendingOperation::OperationType op,
- const std::string& key,
const net::CookieMonster::CanonicalCookie& cc) {
// Commit every 30 seconds.
static const int kCommitIntervalMs = 30 * 1000;
@@ -153,8 +147,7 @@ void SQLitePersistentCookieStore::Backend::BatchOperation(
#endif
// We do a full copy of the cookie here, and hopefully just here.
- scoped_ptr<PendingOperation> po(new PendingOperation(op, key, cc));
- CHECK(po.get());
+ scoped_ptr<PendingOperation> po(new PendingOperation(op, cc));
PendingOperationsList::size_type num_pending;
{
@@ -241,7 +234,7 @@ void SQLitePersistentCookieStore::Backend::Commit() {
case PendingOperation::COOKIE_ADD:
add_smt.Reset();
add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue());
- add_smt.BindString(1, po->key());
+ add_smt.BindString(1, po->cc().Domain());
add_smt.BindString(2, po->cc().Name());
add_smt.BindString(3, po->cc().Value());
add_smt.BindString(4, po->cc().Path());
@@ -276,7 +269,7 @@ void SQLitePersistentCookieStore::Backend::Commit() {
}
}
bool succeeded = transaction.Commit();
- UMA_HISTOGRAM_ENUMERATION("net.CookieBackingStoreUpdateResults",
+ UMA_HISTOGRAM_ENUMERATION("Cookie.BackingStoreUpdateResults",
succeeded ? 0 : 1, 2);
}
@@ -366,7 +359,7 @@ bool InitTable(sql::Connection* db) {
} // namespace
bool SQLitePersistentCookieStore::Load(
- std::vector<net::CookieMonster::KeyedCanonicalCookie>* cookies) {
+ std::vector<net::CookieMonster::CanonicalCookie*>* cookies) {
scoped_ptr<sql::Connection> db(new sql::Connection);
if (!db->Open(path_)) {
NOTREACHED() << "Unable to open cookie DB.";
@@ -410,9 +403,7 @@ bool SQLitePersistentCookieStore::Load(
Time::FromInternalValue(smt.ColumnInt64(5)))); // expires_utc
DLOG_IF(WARNING,
cc->CreationDate() > Time::Now()) << L"CreationDate too recent";
- cookies->push_back(
- net::CookieMonster::KeyedCanonicalCookie(smt.ColumnString(1),
- cc.release()));
+ cookies->push_back(cc.release());
}
// Create the backend, this will take ownership of the db pointer.
@@ -493,10 +484,9 @@ bool SQLitePersistentCookieStore::EnsureDatabaseVersion(sql::Connection* db) {
}
void SQLitePersistentCookieStore::AddCookie(
- const std::string& key,
const net::CookieMonster::CanonicalCookie& cc) {
if (backend_.get())
- backend_->AddCookie(key, cc);
+ backend_->AddCookie(cc);
}
void SQLitePersistentCookieStore::UpdateCookieAccessTime(