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.h" | 5 #include "content/browser/in_process_webkit/indexed_db_context.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop_proxy.h" | |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
13 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" | |
12 #include "content/browser/in_process_webkit/webkit_context.h" | 14 #include "content/browser/in_process_webkit/webkit_context.h" |
13 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
19 #include "webkit/glue/webkit_glue.h" | 21 #include "webkit/glue/webkit_glue.h" |
22 #include "webkit/quota/quota_manager.h" | |
20 #include "webkit/quota/special_storage_policy.h" | 23 #include "webkit/quota/special_storage_policy.h" |
21 | 24 |
22 using WebKit::WebIDBDatabase; | 25 using WebKit::WebIDBDatabase; |
23 using WebKit::WebIDBFactory; | 26 using WebKit::WebIDBFactory; |
24 using WebKit::WebSecurityOrigin; | 27 using WebKit::WebSecurityOrigin; |
25 | 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 void ClearLocalState(const FilePath& indexeddb_path, | 31 void ClearLocalState(const FilePath& indexeddb_path, |
29 quota::SpecialStoragePolicy* special_storage_policy) { | 32 quota::SpecialStoragePolicy* special_storage_policy) { |
(...skipping 17 matching lines...) Expand all Loading... | |
47 } // namespace | 50 } // namespace |
48 | 51 |
49 const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] = | 52 const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] = |
50 FILE_PATH_LITERAL("IndexedDB"); | 53 FILE_PATH_LITERAL("IndexedDB"); |
51 | 54 |
52 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = | 55 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = |
53 FILE_PATH_LITERAL(".indexeddb"); | 56 FILE_PATH_LITERAL(".indexeddb"); |
54 | 57 |
55 IndexedDBContext::IndexedDBContext( | 58 IndexedDBContext::IndexedDBContext( |
56 WebKitContext* webkit_context, | 59 WebKitContext* webkit_context, |
57 quota::SpecialStoragePolicy* special_storage_policy) | 60 quota::SpecialStoragePolicy* special_storage_policy, |
61 quota::QuotaManagerProxy* quota_manager_proxy, | |
62 base::MessageLoopProxy* webkit_thread_loop) | |
58 : clear_local_state_on_exit_(false), | 63 : clear_local_state_on_exit_(false), |
59 special_storage_policy_(special_storage_policy) { | 64 special_storage_policy_(special_storage_policy) { |
60 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); | 65 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); |
66 if (quota_manager_proxy) { | |
67 quota_manager_proxy->RegisterClient( | |
michaeln
2011/05/26 18:12:04
if you have in mind to land just the framing w/o t
dgrogan
2011/05/26 18:28:24
Yeah, that is what I have in mind; I'll comment ou
| |
68 new IndexedDBQuotaClient(webkit_thread_loop, this)); | |
69 } | |
61 } | 70 } |
62 | 71 |
63 IndexedDBContext::~IndexedDBContext() { | 72 IndexedDBContext::~IndexedDBContext() { |
64 // Not being on the WEBKIT thread here means we are running in a unit test | 73 // Not being on the WEBKIT thread here means we are running in a unit test |
65 // where no clean up is needed. | 74 // where no clean up is needed. |
66 if (clear_local_state_on_exit_ && | 75 if (clear_local_state_on_exit_ && |
67 BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { | 76 BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { |
68 ClearLocalState(data_path_, special_storage_policy_); | 77 ClearLocalState(data_path_, special_storage_policy_); |
69 } | 78 } |
70 } | 79 } |
(...skipping 23 matching lines...) Expand all Loading... | |
94 FilePath idb_file = GetIndexedDBFilePath(origin_id); | 103 FilePath idb_file = GetIndexedDBFilePath(origin_id); |
95 DCHECK_EQ(idb_file.BaseName().value().substr(0, strlen("chrome-extension")), | 104 DCHECK_EQ(idb_file.BaseName().value().substr(0, strlen("chrome-extension")), |
96 FILE_PATH_LITERAL("chrome-extension")); | 105 FILE_PATH_LITERAL("chrome-extension")); |
97 DeleteIndexedDBFile(GetIndexedDBFilePath(origin_id)); | 106 DeleteIndexedDBFile(GetIndexedDBFilePath(origin_id)); |
98 } | 107 } |
99 | 108 |
100 bool IndexedDBContext::IsUnlimitedStorageGranted( | 109 bool IndexedDBContext::IsUnlimitedStorageGranted( |
101 const GURL& origin) const { | 110 const GURL& origin) const { |
102 return special_storage_policy_->IsStorageUnlimited(origin); | 111 return special_storage_policy_->IsStorageUnlimited(origin); |
103 } | 112 } |
OLD | NEW |