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

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

Issue 8820009: Appcache, local storage, indexed db, databases: skip exit-time deletion when restarting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 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 | Annotate | Revision Log
OLDNEW
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/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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = 89 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] =
90 FILE_PATH_LITERAL(".leveldb"); 90 FILE_PATH_LITERAL(".leveldb");
91 91
92 IndexedDBContext::IndexedDBContext( 92 IndexedDBContext::IndexedDBContext(
93 WebKitContext* webkit_context, 93 WebKitContext* webkit_context,
94 quota::SpecialStoragePolicy* special_storage_policy, 94 quota::SpecialStoragePolicy* special_storage_policy,
95 quota::QuotaManagerProxy* quota_manager_proxy, 95 quota::QuotaManagerProxy* quota_manager_proxy,
96 base::MessageLoopProxy* webkit_thread_loop) 96 base::MessageLoopProxy* webkit_thread_loop)
97 : clear_local_state_on_exit_(false), 97 : clear_local_state_on_exit_(false),
98 save_session_state_(false),
98 special_storage_policy_(special_storage_policy), 99 special_storage_policy_(special_storage_policy),
99 quota_manager_proxy_(quota_manager_proxy) { 100 quota_manager_proxy_(quota_manager_proxy) {
100 if (!webkit_context->is_incognito()) 101 if (!webkit_context->is_incognito())
101 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); 102 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory);
102 if (quota_manager_proxy && 103 if (quota_manager_proxy &&
103 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { 104 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) {
104 quota_manager_proxy->RegisterClient( 105 quota_manager_proxy->RegisterClient(
105 new IndexedDBQuotaClient(webkit_thread_loop, this)); 106 new IndexedDBQuotaClient(webkit_thread_loop, this));
106 } 107 }
107 } 108 }
108 109
109 IndexedDBContext::~IndexedDBContext() { 110 IndexedDBContext::~IndexedDBContext() {
110 WebKit::WebIDBFactory* factory = idb_factory_.release(); 111 WebKit::WebIDBFactory* factory = idb_factory_.release();
111 if (factory) 112 if (factory)
112 BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, factory); 113 BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, factory);
113 114
114 if (data_path_.empty()) 115 if (data_path_.empty())
115 return; 116 return;
116 117
118 if (save_session_state_)
119 return;
120
117 bool has_session_only_databases = 121 bool has_session_only_databases =
118 special_storage_policy_.get() && 122 special_storage_policy_.get() &&
119 special_storage_policy_->HasSessionOnlyOrigins(); 123 special_storage_policy_->HasSessionOnlyOrigins();
120 124
121 // Clearning only session-only databases, and there are none. 125 // Clearning only session-only databases, and there are none.
122 if (!clear_local_state_on_exit_ && 126 if (!clear_local_state_on_exit_ && !has_session_only_databases)
123 !has_session_only_databases)
124 return; 127 return;
125 128
126 // No WEBKIT thread here means we are running in a unit test where no clean 129 // No WEBKIT thread here means we are running in a unit test where no clean
127 // up is needed. 130 // up is needed.
128 BrowserThread::PostTask( 131 BrowserThread::PostTask(
129 BrowserThread::WEBKIT, FROM_HERE, 132 BrowserThread::WEBKIT, FROM_HERE,
130 base::Bind(&ClearLocalState, data_path_, clear_local_state_on_exit_, 133 base::Bind(&ClearLocalState, data_path_, clear_local_state_on_exit_,
131 special_storage_policy_)); 134 special_storage_policy_));
132 } 135 }
133 136
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 337 }
335 } 338 }
336 return origin_set_.get(); 339 return origin_set_.get();
337 } 340 }
338 341
339 void IndexedDBContext::ResetCaches() { 342 void IndexedDBContext::ResetCaches() {
340 origin_set_.reset(); 343 origin_set_.reset();
341 origin_size_map_.clear(); 344 origin_size_map_.clear();
342 space_available_map_.clear(); 345 space_available_map_.clear();
343 } 346 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_context.h ('k') | content/browser/in_process_webkit/webkit_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698