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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_context_impl.cc

Issue 10447117: Unwire the clear on exit preference from the storage systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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 "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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 WebKit::WebString origin_id_webstring = 54 WebKit::WebString origin_id_webstring =
55 webkit_glue::FilePathToWebString(file_path.BaseName()); 55 webkit_glue::FilePathToWebString(file_path.BaseName());
56 origins->push_back( 56 origins->push_back(
57 DatabaseUtil::GetOriginFromIdentifier(origin_id_webstring)); 57 DatabaseUtil::GetOriginFromIdentifier(origin_id_webstring));
58 if (file_paths) 58 if (file_paths)
59 file_paths->push_back(file_path); 59 file_paths->push_back(file_path);
60 } 60 }
61 } 61 }
62 } 62 }
63 63
64 // If clear_all_databases is true, deletes all databases not protected by 64 // Deletes session-only databases.
65 // special storage policy. Otherwise deletes session-only databases.
66 void ClearLocalState( 65 void ClearLocalState(
michaeln 2012/06/01 02:06:17 ditto, name is odd now
67 const FilePath& indexeddb_path, 66 const FilePath& indexeddb_path,
68 bool clear_all_databases,
69 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { 67 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
71 std::vector<GURL> origins; 69 std::vector<GURL> origins;
72 std::vector<FilePath> file_paths; 70 std::vector<FilePath> file_paths;
73 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths); 71 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths);
74 DCHECK_EQ(origins.size(), file_paths.size()); 72 DCHECK_EQ(origins.size(), file_paths.size());
75 std::vector<FilePath>::const_iterator file_path_iter = file_paths.begin(); 73 std::vector<FilePath>::const_iterator file_path_iter = file_paths.begin();
76 for (std::vector<GURL>::const_iterator iter = origins.begin(); 74 for (std::vector<GURL>::const_iterator iter = origins.begin();
77 iter != origins.end(); ++iter, ++file_path_iter) { 75 iter != origins.end(); ++iter, ++file_path_iter) {
78 if (!clear_all_databases && 76 if (!special_storage_policy->IsStorageSessionOnly(*iter))
79 !special_storage_policy->IsStorageSessionOnly(*iter)) {
80 continue; 77 continue;
81 }
82 if (special_storage_policy.get() && 78 if (special_storage_policy.get() &&
83 special_storage_policy->IsStorageProtected(*iter)) 79 special_storage_policy->IsStorageProtected(*iter))
84 continue; 80 continue;
85 file_util::Delete(*file_path_iter, true); 81 file_util::Delete(*file_path_iter, true);
86 } 82 }
87 } 83 }
88 84
89 } // namespace 85 } // namespace
90 86
91 IndexedDBContextImpl::IndexedDBContextImpl( 87 IndexedDBContextImpl::IndexedDBContextImpl(
92 const FilePath& data_path, 88 const FilePath& data_path,
93 quota::SpecialStoragePolicy* special_storage_policy, 89 quota::SpecialStoragePolicy* special_storage_policy,
94 quota::QuotaManagerProxy* quota_manager_proxy, 90 quota::QuotaManagerProxy* quota_manager_proxy,
95 base::MessageLoopProxy* webkit_thread_loop) 91 base::MessageLoopProxy* webkit_thread_loop)
96 : clear_local_state_on_exit_(false), 92 : save_session_state_(false),
97 save_session_state_(false),
98 special_storage_policy_(special_storage_policy), 93 special_storage_policy_(special_storage_policy),
99 quota_manager_proxy_(quota_manager_proxy) { 94 quota_manager_proxy_(quota_manager_proxy) {
100 if (!data_path.empty()) 95 if (!data_path.empty())
101 data_path_ = data_path.Append(kIndexedDBDirectory); 96 data_path_ = data_path.Append(kIndexedDBDirectory);
102 if (quota_manager_proxy && 97 if (quota_manager_proxy &&
103 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { 98 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) {
104 quota_manager_proxy->RegisterClient( 99 quota_manager_proxy->RegisterClient(
105 new IndexedDBQuotaClient(webkit_thread_loop, this)); 100 new IndexedDBQuotaClient(webkit_thread_loop, this));
106 } 101 }
107 } 102 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return; 233 return;
239 234
240 if (save_session_state_) 235 if (save_session_state_)
241 return; 236 return;
242 237
243 bool has_session_only_databases = 238 bool has_session_only_databases =
244 special_storage_policy_.get() && 239 special_storage_policy_.get() &&
245 special_storage_policy_->HasSessionOnlyOrigins(); 240 special_storage_policy_->HasSessionOnlyOrigins();
246 241
247 // Clearning only session-only databases, and there are none. 242 // Clearning only session-only databases, and there are none.
248 if (!clear_local_state_on_exit_ && !has_session_only_databases) 243 if (!has_session_only_databases)
249 return; 244 return;
250 245
251 // No WEBKIT thread here means we are running in a unit test where no clean 246 // No WEBKIT thread here means we are running in a unit test where no clean
252 // up is needed. 247 // up is needed.
253 BrowserThread::PostTask( 248 BrowserThread::PostTask(
254 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 249 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
255 base::Bind(&ClearLocalState, data_path_, clear_local_state_on_exit_, 250 base::Bind(&ClearLocalState, data_path_, special_storage_policy_));
256 special_storage_policy_));
257 } 251 }
258 252
259 FilePath IndexedDBContextImpl::GetIndexedDBFilePath( 253 FilePath IndexedDBContextImpl::GetIndexedDBFilePath(
260 const string16& origin_id) const { 254 const string16& origin_id) const {
261 DCHECK(!data_path_.empty()); 255 DCHECK(!data_path_.empty());
262 FilePath::StringType id = 256 FilePath::StringType id =
263 webkit_glue::WebStringToFilePathString(origin_id).append( 257 webkit_glue::WebStringToFilePathString(origin_id).append(
264 FILE_PATH_LITERAL(".indexeddb")); 258 FILE_PATH_LITERAL(".indexeddb"));
265 return data_path_.Append(id.append(kIndexedDBExtension)); 259 return data_path_.Append(id.append(kIndexedDBExtension));
266 } 260 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 342 }
349 } 343 }
350 return origin_set_.get(); 344 return origin_set_.get();
351 } 345 }
352 346
353 void IndexedDBContextImpl::ResetCaches() { 347 void IndexedDBContextImpl::ResetCaches() {
354 origin_set_.reset(); 348 origin_set_.reset();
355 origin_size_map_.clear(); 349 origin_size_map_.clear();
356 space_available_map_.clear(); 350 space_available_map_.clear();
357 } 351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698