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

Side by Side Diff: webkit/dom_storage/dom_storage_context.cc

Issue 9726022: Revert 127573 - DOMStorageContextImpl that's implemented in terms of the new dom_storage classes. A… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/dom_storage/dom_storage_context.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dom_storage/dom_storage_context.h" 5 #include "webkit/dom_storage/dom_storage_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h"
10 #include "base/time.h" 9 #include "base/time.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
13 #include "webkit/dom_storage/dom_storage_area.h"
14 #include "webkit/dom_storage/dom_storage_namespace.h" 10 #include "webkit/dom_storage/dom_storage_namespace.h"
15 #include "webkit/dom_storage/dom_storage_task_runner.h" 11 #include "webkit/dom_storage/dom_storage_task_runner.h"
16 #include "webkit/dom_storage/dom_storage_types.h" 12 #include "webkit/dom_storage/dom_storage_types.h"
17 #include "webkit/glue/webkit_glue.h"
18 #include "webkit/quota/special_storage_policy.h" 13 #include "webkit/quota/special_storage_policy.h"
19 14
20 using file_util::FileEnumerator;
21
22 namespace dom_storage { 15 namespace dom_storage {
23 16
24 DomStorageContext::UsageInfo::UsageInfo() {}
25 DomStorageContext::UsageInfo::~UsageInfo() {}
26
27 DomStorageContext::DomStorageContext( 17 DomStorageContext::DomStorageContext(
28 const FilePath& directory, 18 const FilePath& directory,
29 quota::SpecialStoragePolicy* special_storage_policy, 19 quota::SpecialStoragePolicy* special_storage_policy,
30 DomStorageTaskRunner* task_runner) 20 DomStorageTaskRunner* task_runner)
31 : directory_(directory), 21 : directory_(directory),
32 task_runner_(task_runner), 22 task_runner_(task_runner) {
33 clear_local_state_(false),
34 save_session_state_(false),
35 special_storage_policy_(special_storage_policy) {
36 // AtomicSequenceNum starts at 0 but we want to start session 23 // AtomicSequenceNum starts at 0 but we want to start session
37 // namespace ids at one since zero is reserved for the 24 // namespace ids at one since zero is reserved for the
38 // kLocalStorageNamespaceId. 25 // kLocalStorageNamespaceId.
39 session_id_sequence_.GetNext(); 26 session_id_sequence_.GetNext();
40 } 27 }
41 28
42 DomStorageContext::~DomStorageContext() { 29 DomStorageContext::~DomStorageContext() {
43 } 30 }
44 31
45 DomStorageNamespace* DomStorageContext::GetStorageNamespace( 32 DomStorageNamespace* DomStorageContext::GetStorageNamespace(
46 int64 namespace_id) { 33 int64 namespace_id) {
47 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id); 34 StorageNamespaceMap::iterator found = namespaces_.find(namespace_id);
48 if (found == namespaces_.end()) { 35 if (found == namespaces_.end()) {
49 if (namespace_id == kLocalStorageNamespaceId) { 36 if (namespace_id == kLocalStorageNamespaceId) {
50 DomStorageNamespace* local = 37 DomStorageNamespace* local =
51 new DomStorageNamespace(directory_, task_runner_); 38 new DomStorageNamespace(directory_, task_runner_);
52 namespaces_[kLocalStorageNamespaceId] = local; 39 namespaces_[kLocalStorageNamespaceId] = local;
53 return local; 40 return local;
54 } 41 }
55 return NULL; 42 return NULL;
56 } 43 }
57 return found->second; 44 return found->second;
58 } 45 }
59 46
60 void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos) {
61 FileEnumerator enumerator(directory_, false, FileEnumerator::FILES);
62 for (FilePath path = enumerator.Next(); !path.empty();
63 path = enumerator.Next()) {
64 if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) {
65 UsageInfo info;
66
67 // Extract origin id from the path and construct a GURL.
68 WebKit::WebString origin_id = webkit_glue::FilePathToWebString(
69 path.BaseName().RemoveExtension());
70 info.origin = GURL(WebKit::WebSecurityOrigin::
71 createFromDatabaseIdentifier(origin_id).toString());
72
73 FileEnumerator::FindInfo find_info;
74 enumerator.GetFindInfo(&find_info);
75 info.data_size = FileEnumerator::GetFilesize(find_info);
76 info.last_modified = FileEnumerator::GetLastModifiedTime(find_info);
77
78 infos->push_back(info);
79 }
80 }
81 }
82
83 void DomStorageContext::DeleteOrigin(const GURL& origin) {
84 // TODO(michaeln): write me
85 }
86
87 void DomStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
88 // TODO(michaeln): write me
89 }
90
91 void DomStorageContext::PurgeMemory() {
92 // TODO(michaeln): write me
93 }
94
95 void DomStorageContext::Shutdown() {
96 // TODO(michaeln): write me
97 }
98
99 void DomStorageContext::AddEventObserver(EventObserver* observer) { 47 void DomStorageContext::AddEventObserver(EventObserver* observer) {
100 event_observers_.AddObserver(observer); 48 event_observers_.AddObserver(observer);
101 } 49 }
102 50
103 void DomStorageContext::RemoveEventObserver(EventObserver* observer) { 51 void DomStorageContext::RemoveEventObserver(EventObserver* observer) {
104 event_observers_.RemoveObserver(observer); 52 event_observers_.RemoveObserver(observer);
105 } 53 }
106 54
107 void DomStorageContext::NotifyItemSet( 55 void DomStorageContext::NotifyItemSet(
108 const DomStorageArea* area, 56 const DomStorageArea* area,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DCHECK_NE(kLocalStorageNamespaceId, existing_id); 100 DCHECK_NE(kLocalStorageNamespaceId, existing_id);
153 DCHECK_NE(kLocalStorageNamespaceId, new_id); 101 DCHECK_NE(kLocalStorageNamespaceId, new_id);
154 StorageNamespaceMap::iterator found = namespaces_.find(existing_id); 102 StorageNamespaceMap::iterator found = namespaces_.find(existing_id);
155 if (found != namespaces_.end()) 103 if (found != namespaces_.end())
156 namespaces_[new_id] = found->second->Clone(new_id); 104 namespaces_[new_id] = found->second->Clone(new_id);
157 else 105 else
158 CreateSessionNamespace(new_id); 106 CreateSessionNamespace(new_id);
159 } 107 }
160 108
161 } // namespace dom_storage 109 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698