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 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" | 5 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/bind.h" | 10 #include "base/bind.h" |
12 #include "base/callback.h" | 11 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
15 #include "base/location.h" | 14 #include "base/location.h" |
16 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
20 #include "base/profiler/scoped_tracker.h" | 20 #include "base/profiler/scoped_tracker.h" |
21 #include "base/sequenced_task_runner.h" | 21 #include "base/sequenced_task_runner.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
25 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 return db_ != NULL; | 591 return db_ != NULL; |
592 } | 592 } |
593 | 593 |
594 base::Time start = base::Time::Now(); | 594 base::Time start = base::Time::Now(); |
595 | 595 |
596 const base::FilePath dir = path_.DirName(); | 596 const base::FilePath dir = path_.DirName(); |
597 if (!base::PathExists(dir) && !base::CreateDirectory(dir)) { | 597 if (!base::PathExists(dir) && !base::CreateDirectory(dir)) { |
598 return false; | 598 return false; |
599 } | 599 } |
600 | 600 |
601 int64 db_size = 0; | 601 int64_t db_size = 0; |
602 if (base::GetFileSize(path_, &db_size)) | 602 if (base::GetFileSize(path_, &db_size)) |
603 UMA_HISTOGRAM_COUNTS("Cookie.DBSizeInKB", db_size / 1024); | 603 UMA_HISTOGRAM_COUNTS("Cookie.DBSizeInKB", db_size / 1024); |
604 | 604 |
605 db_.reset(new sql::Connection); | 605 db_.reset(new sql::Connection); |
606 db_->set_histogram_tag("Cookie"); | 606 db_->set_histogram_tag("Cookie"); |
607 | 607 |
608 // Unretained to avoid a ref loop with |db_|. | 608 // Unretained to avoid a ref loop with |db_|. |
609 db_->set_error_callback( | 609 db_->set_error_callback( |
610 base::Bind(&SQLitePersistentCookieStore::Backend::DatabaseErrorCallback, | 610 base::Bind(&SQLitePersistentCookieStore::Backend::DatabaseErrorCallback, |
611 base::Unretained(this))); | 611 base::Unretained(this))); |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 1395 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
1396 if (backend_) | 1396 if (backend_) |
1397 backend_->Flush(callback); | 1397 backend_->Flush(callback); |
1398 } | 1398 } |
1399 | 1399 |
1400 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { | 1400 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { |
1401 Close(base::Closure()); | 1401 Close(base::Closure()); |
1402 } | 1402 } |
1403 | 1403 |
1404 } // namespace net | 1404 } // namespace net |
OLD | NEW |