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

Side by Side Diff: content/browser/indexed_db/indexed_db_context_impl.h

Issue 671873004: Migrates legacy packaged app data when it's upgraded to a platform app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments and adds tests Created 6 years 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
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 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 27 matching lines...) Expand all
38 class IndexedDBConnection; 38 class IndexedDBConnection;
39 39
40 class CONTENT_EXPORT IndexedDBContextImpl 40 class CONTENT_EXPORT IndexedDBContextImpl
41 : NON_EXPORTED_BASE(public IndexedDBContext) { 41 : NON_EXPORTED_BASE(public IndexedDBContext) {
42 public: 42 public:
43 // Recorded in histograms, so append only. 43 // Recorded in histograms, so append only.
44 enum ForceCloseReason { 44 enum ForceCloseReason {
45 FORCE_CLOSE_DELETE_ORIGIN = 0, 45 FORCE_CLOSE_DELETE_ORIGIN = 0,
46 FORCE_CLOSE_BACKING_STORE_FAILURE, 46 FORCE_CLOSE_BACKING_STORE_FAILURE,
47 FORCE_CLOSE_INTERNALS_PAGE, 47 FORCE_CLOSE_INTERNALS_PAGE,
48 FORCE_CLOSE_COPY_ORIGIN,
48 FORCE_CLOSE_REASON_MAX 49 FORCE_CLOSE_REASON_MAX
49 }; 50 };
50 51
51 // The indexed db directory. 52 // The indexed db directory.
52 static const base::FilePath::CharType kIndexedDBDirectory[]; 53 static const base::FilePath::CharType kIndexedDBDirectory[];
53 54
54 // If |data_path| is empty, nothing will be saved to disk. 55 // If |data_path| is empty, nothing will be saved to disk.
55 IndexedDBContextImpl(const base::FilePath& data_path, 56 IndexedDBContextImpl(const base::FilePath& data_path,
56 storage::SpecialStoragePolicy* special_storage_policy, 57 storage::SpecialStoragePolicy* special_storage_policy,
57 storage::QuotaManagerProxy* quota_manager_proxy, 58 storage::QuotaManagerProxy* quota_manager_proxy,
58 base::SequencedTaskRunner* task_runner); 59 base::SequencedTaskRunner* task_runner);
59 60
60 IndexedDBFactory* GetIDBFactory(); 61 IndexedDBFactory* GetIDBFactory();
61 62
62 // Disables the exit-time deletion of session-only data. 63 // Disables the exit-time deletion of session-only data.
63 void SetForceKeepSessionState() { force_keep_session_state_ = true; } 64 void SetForceKeepSessionState() { force_keep_session_state_ = true; }
64 65
65 // IndexedDBContext implementation: 66 // IndexedDBContext implementation:
66 base::SequencedTaskRunner* TaskRunner() const override; 67 base::SequencedTaskRunner* TaskRunner() const override;
67 std::vector<IndexedDBInfo> GetAllOriginsInfo() override; 68 std::vector<IndexedDBInfo> GetAllOriginsInfo() override;
68 int64 GetOriginDiskUsage(const GURL& origin_url) override; 69 int64 GetOriginDiskUsage(const GURL& origin_url) override;
69 void DeleteForOrigin(const GURL& origin_url) override; 70 void DeleteForOrigin(const GURL& origin_url) override;
70 base::FilePath GetFilePathForTesting( 71 void CopyOriginData(const GURL& origin_url,
71 const std::string& origin_id) const override; 72 IndexedDBContext* dest_context) override;
73 base::FilePath GetFilePath(const GURL& origin_url) const override;
72 void SetTaskRunnerForTesting(base::SequencedTaskRunner* task_runner) override; 74 void SetTaskRunnerForTesting(base::SequencedTaskRunner* task_runner) override;
73 75
74 // Methods called by IndexedDBDispatcherHost for quota support. 76 // Methods called by IndexedDBDispatcherHost for quota support.
75 void ConnectionOpened(const GURL& origin_url, IndexedDBConnection* db); 77 void ConnectionOpened(const GURL& origin_url, IndexedDBConnection* db);
76 void ConnectionClosed(const GURL& origin_url, IndexedDBConnection* db); 78 void ConnectionClosed(const GURL& origin_url, IndexedDBConnection* db);
77 void TransactionComplete(const GURL& origin_url); 79 void TransactionComplete(const GURL& origin_url);
78 void DatabaseDeleted(const GURL& origin_url); 80 void DatabaseDeleted(const GURL& origin_url);
79 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); 81 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes);
80 bool IsOverQuota(const GURL& origin_url); 82 bool IsOverQuota(const GURL& origin_url);
81 83
82 storage::QuotaManagerProxy* quota_manager_proxy(); 84 storage::QuotaManagerProxy* quota_manager_proxy();
83 85
84 std::vector<GURL> GetAllOrigins(); 86 std::vector<GURL> GetAllOrigins();
85 base::Time GetOriginLastModified(const GURL& origin_url); 87 base::Time GetOriginLastModified(const GURL& origin_url);
86 base::ListValue* GetAllOriginsDetails(); 88 base::ListValue* GetAllOriginsDetails();
87 89
88 // ForceClose takes a value rather than a reference since it may release the 90 // ForceClose takes a value rather than a reference since it may release the
89 // owning object. 91 // owning object.
90 void ForceClose(const GURL origin_url, ForceCloseReason reason); 92 void ForceClose(const GURL origin_url, ForceCloseReason reason);
91 93
92 base::FilePath GetFilePath(const GURL& origin_url) const;
93 base::FilePath data_path() const { return data_path_; } 94 base::FilePath data_path() const { return data_path_; }
94 bool IsInOriginSet(const GURL& origin_url) { 95 bool IsInOriginSet(const GURL& origin_url) {
95 std::set<GURL>* set = GetOriginSet(); 96 std::set<GURL>* set = GetOriginSet();
96 return set->find(origin_url) != set->end(); 97 return set->find(origin_url) != set->end();
97 } 98 }
98 size_t GetConnectionCount(const GURL& origin_url); 99 size_t GetConnectionCount(const GURL& origin_url);
99 100
100 // For unit tests allow to override the |data_path_|. 101 // For unit tests allow to override the |data_path_|.
101 void set_data_path_for_testing(const base::FilePath& data_path) { 102 void set_data_path_for_testing(const base::FilePath& data_path) {
102 data_path_ = data_path; 103 data_path_ = data_path;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 scoped_ptr<std::set<GURL> > origin_set_; 150 scoped_ptr<std::set<GURL> > origin_set_;
150 OriginToSizeMap origin_size_map_; 151 OriginToSizeMap origin_size_map_;
151 OriginToSizeMap space_available_map_; 152 OriginToSizeMap space_available_map_;
152 153
153 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); 154 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl);
154 }; 155 };
155 156
156 } // namespace content 157 } // namespace content
157 158
158 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 159 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698