OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/in_process_webkit/indexed_db_context_impl.h" | 5 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" | 14 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" |
15 #include "content/browser/in_process_webkit/webkit_context.h" | |
16 #include "content/public/browser/browser_context.h" | |
17 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
24 #include "webkit/database/database_util.h" | 22 #include "webkit/database/database_util.h" |
25 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
26 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
27 #include "webkit/quota/special_storage_policy.h" | 25 #include "webkit/quota/special_storage_policy.h" |
28 | 26 |
29 using content::BrowserContext; | |
30 using content::BrowserThread; | 27 using content::BrowserThread; |
31 using content::IndexedDBContext; | 28 using content::IndexedDBContext; |
32 using webkit_database::DatabaseUtil; | 29 using webkit_database::DatabaseUtil; |
33 using WebKit::WebIDBDatabase; | 30 using WebKit::WebIDBDatabase; |
34 using WebKit::WebIDBFactory; | 31 using WebKit::WebIDBFactory; |
35 using WebKit::WebSecurityOrigin; | 32 using WebKit::WebSecurityOrigin; |
36 | 33 |
37 const FilePath::CharType IndexedDBContextImpl::kIndexedDBDirectory[] = | 34 const FilePath::CharType IndexedDBContextImpl::kIndexedDBDirectory[] = |
38 FILE_PATH_LITERAL("IndexedDB"); | 35 FILE_PATH_LITERAL("IndexedDB"); |
39 | 36 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 81 } |
85 if (special_storage_policy.get() && | 82 if (special_storage_policy.get() && |
86 special_storage_policy->IsStorageProtected(*iter)) | 83 special_storage_policy->IsStorageProtected(*iter)) |
87 continue; | 84 continue; |
88 file_util::Delete(*file_path_iter, true); | 85 file_util::Delete(*file_path_iter, true); |
89 } | 86 } |
90 } | 87 } |
91 | 88 |
92 } // namespace | 89 } // namespace |
93 | 90 |
94 IndexedDBContext* IndexedDBContext::GetForBrowserContext( | |
95 BrowserContext* context) { | |
96 return BrowserContext::GetWebKitContext(context)->indexed_db_context(); | |
97 } | |
98 | |
99 IndexedDBContextImpl::IndexedDBContextImpl( | 91 IndexedDBContextImpl::IndexedDBContextImpl( |
100 WebKitContext* webkit_context, | 92 const FilePath& data_path, |
101 quota::SpecialStoragePolicy* special_storage_policy, | 93 quota::SpecialStoragePolicy* special_storage_policy, |
102 quota::QuotaManagerProxy* quota_manager_proxy, | 94 quota::QuotaManagerProxy* quota_manager_proxy, |
103 base::MessageLoopProxy* webkit_thread_loop) | 95 base::MessageLoopProxy* webkit_thread_loop) |
104 : clear_local_state_on_exit_(false), | 96 : clear_local_state_on_exit_(false), |
105 save_session_state_(false), | 97 save_session_state_(false), |
106 special_storage_policy_(special_storage_policy), | 98 special_storage_policy_(special_storage_policy), |
107 quota_manager_proxy_(quota_manager_proxy) { | 99 quota_manager_proxy_(quota_manager_proxy) { |
108 if (!webkit_context->is_incognito()) | 100 if (!data_path.empty()) |
109 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); | 101 data_path_ = data_path.Append(kIndexedDBDirectory); |
110 if (quota_manager_proxy && | 102 if (quota_manager_proxy && |
111 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | 103 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { |
112 quota_manager_proxy->RegisterClient( | 104 quota_manager_proxy->RegisterClient( |
113 new IndexedDBQuotaClient(webkit_thread_loop, this)); | 105 new IndexedDBQuotaClient(webkit_thread_loop, this)); |
114 } | 106 } |
115 } | 107 } |
116 | 108 |
117 IndexedDBContextImpl::~IndexedDBContextImpl() { | 109 IndexedDBContextImpl::~IndexedDBContextImpl() { |
118 WebKit::WebIDBFactory* factory = idb_factory_.release(); | 110 WebKit::WebIDBFactory* factory = idb_factory_.release(); |
119 if (factory) { | 111 if (factory) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 348 } |
357 } | 349 } |
358 return origin_set_.get(); | 350 return origin_set_.get(); |
359 } | 351 } |
360 | 352 |
361 void IndexedDBContextImpl::ResetCaches() { | 353 void IndexedDBContextImpl::ResetCaches() { |
362 origin_set_.reset(); | 354 origin_set_.reset(); |
363 origin_size_map_.clear(); | 355 origin_size_map_.clear(); |
364 space_available_map_.clear(); | 356 space_available_map_.clear(); |
365 } | 357 } |
OLD | NEW |