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 "webkit/browser/dom_storage/dom_storage_area.h" | 5 #include "webkit/browser/dom_storage/dom_storage_area.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
14 #include "webkit/base/file_path_string_conversions.h" | 14 #include "webkit/base/file_path_string_conversions.h" |
15 #include "webkit/base/origin_url_conversions.h" | |
16 #include "webkit/browser/database/database_util.h" | 15 #include "webkit/browser/database/database_util.h" |
17 #include "webkit/browser/dom_storage/dom_storage_namespace.h" | 16 #include "webkit/browser/dom_storage/dom_storage_namespace.h" |
18 #include "webkit/browser/dom_storage/dom_storage_task_runner.h" | 17 #include "webkit/browser/dom_storage/dom_storage_task_runner.h" |
19 #include "webkit/browser/dom_storage/local_storage_database_adapter.h" | 18 #include "webkit/browser/dom_storage/local_storage_database_adapter.h" |
20 #include "webkit/browser/dom_storage/session_storage_database.h" | 19 #include "webkit/browser/dom_storage/session_storage_database.h" |
21 #include "webkit/browser/dom_storage/session_storage_database_adapter.h" | 20 #include "webkit/browser/dom_storage/session_storage_database_adapter.h" |
| 21 #include "webkit/common/database/database_identifier.h" |
22 #include "webkit/common/dom_storage/dom_storage_map.h" | 22 #include "webkit/common/dom_storage/dom_storage_map.h" |
23 #include "webkit/common/dom_storage/dom_storage_types.h" | 23 #include "webkit/common/dom_storage/dom_storage_types.h" |
24 #include "webkit/common/fileapi/file_system_util.h" | 24 #include "webkit/common/fileapi/file_system_util.h" |
25 | 25 |
26 using webkit_database::DatabaseUtil; | 26 using webkit_database::DatabaseUtil; |
27 | 27 |
28 namespace dom_storage { | 28 namespace dom_storage { |
29 | 29 |
30 static const int kCommitTimerSeconds = 1; | 30 static const int kCommitTimerSeconds = 1; |
31 | 31 |
32 DomStorageArea::CommitBatch::CommitBatch() | 32 DomStorageArea::CommitBatch::CommitBatch() |
33 : clear_all_first(false) { | 33 : clear_all_first(false) { |
34 } | 34 } |
35 DomStorageArea::CommitBatch::~CommitBatch() {} | 35 DomStorageArea::CommitBatch::~CommitBatch() {} |
36 | 36 |
37 | 37 |
38 // static | 38 // static |
39 const base::FilePath::CharType DomStorageArea::kDatabaseFileExtension[] = | 39 const base::FilePath::CharType DomStorageArea::kDatabaseFileExtension[] = |
40 FILE_PATH_LITERAL(".localstorage"); | 40 FILE_PATH_LITERAL(".localstorage"); |
41 | 41 |
42 // static | 42 // static |
43 base::FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { | 43 base::FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { |
44 std::string filename = webkit_base::GetOriginIdentifierFromURL(origin); | 44 std::string filename = webkit_database::GetIdentifierFromOrigin(origin); |
45 // There is no base::FilePath.AppendExtension() method, so start with just the | 45 // There is no base::FilePath.AppendExtension() method, so start with just the |
46 // extension as the filename, and then InsertBeforeExtension the desired | 46 // extension as the filename, and then InsertBeforeExtension the desired |
47 // name. | 47 // name. |
48 return base::FilePath().Append(kDatabaseFileExtension). | 48 return base::FilePath().Append(kDatabaseFileExtension). |
49 InsertBeforeExtensionASCII(filename); | 49 InsertBeforeExtensionASCII(filename); |
50 } | 50 } |
51 | 51 |
52 // static | 52 // static |
53 GURL DomStorageArea::OriginFromDatabaseFileName(const base::FilePath& name) { | 53 GURL DomStorageArea::OriginFromDatabaseFileName(const base::FilePath& name) { |
54 DCHECK(name.MatchesExtension(kDatabaseFileExtension)); | 54 DCHECK(name.MatchesExtension(kDatabaseFileExtension)); |
55 std::string origin_id = | 55 std::string origin_id = |
56 name.BaseName().RemoveExtension().MaybeAsASCII(); | 56 name.BaseName().RemoveExtension().MaybeAsASCII(); |
57 return webkit_base::GetOriginURLFromIdentifier(origin_id); | 57 return webkit_database::GetOriginFromIdentifier(origin_id); |
58 } | 58 } |
59 | 59 |
60 DomStorageArea::DomStorageArea(const GURL& origin, const base::FilePath& directo
ry, | 60 DomStorageArea::DomStorageArea(const GURL& origin, const base::FilePath& directo
ry, |
61 DomStorageTaskRunner* task_runner) | 61 DomStorageTaskRunner* task_runner) |
62 : namespace_id_(kLocalStorageNamespaceId), origin_(origin), | 62 : namespace_id_(kLocalStorageNamespaceId), origin_(origin), |
63 directory_(directory), | 63 directory_(directory), |
64 task_runner_(task_runner), | 64 task_runner_(task_runner), |
65 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)), | 65 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)), |
66 is_initial_import_done_(true), | 66 is_initial_import_done_(true), |
67 is_shutdown_(false), | 67 is_shutdown_(false), |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 commit_batch_->clear_all_first, | 389 commit_batch_->clear_all_first, |
390 commit_batch_->changed_values); | 390 commit_batch_->changed_values); |
391 DCHECK(success); | 391 DCHECK(success); |
392 } | 392 } |
393 commit_batch_.reset(); | 393 commit_batch_.reset(); |
394 backing_.reset(); | 394 backing_.reset(); |
395 session_storage_backing_ = NULL; | 395 session_storage_backing_ = NULL; |
396 } | 396 } |
397 | 397 |
398 } // namespace dom_storage | 398 } // namespace dom_storage |
OLD | NEW |