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

Side by Side Diff: content/browser/renderer_host/database_message_filter.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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/renderer_host/database_message_filter.h" 5 #include "content/browser/renderer_host/database_message_filter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 26 matching lines...) Expand all
37 37
38 const int kNumDeleteRetries = 2; 38 const int kNumDeleteRetries = 2;
39 const int kDelayDeleteRetryMs = 100; 39 const int kDelayDeleteRetryMs = 100;
40 40
41 } // namespace 41 } // namespace
42 42
43 DatabaseMessageFilter::DatabaseMessageFilter( 43 DatabaseMessageFilter::DatabaseMessageFilter(
44 webkit_database::DatabaseTracker* db_tracker) 44 webkit_database::DatabaseTracker* db_tracker)
45 : db_tracker_(db_tracker), 45 : db_tracker_(db_tracker),
46 observer_added_(false) { 46 observer_added_(false) {
47 DCHECK(db_tracker_); 47 DCHECK(db_tracker_.get());
48 } 48 }
49 49
50 void DatabaseMessageFilter::OnChannelClosing() { 50 void DatabaseMessageFilter::OnChannelClosing() {
51 BrowserMessageFilter::OnChannelClosing(); 51 BrowserMessageFilter::OnChannelClosing();
52 if (observer_added_) { 52 if (observer_added_) {
53 observer_added_ = false; 53 observer_added_ = false;
54 BrowserThread::PostTask( 54 BrowserThread::PostTask(
55 BrowserThread::FILE, FROM_HERE, 55 BrowserThread::FILE, FROM_HERE,
56 base::Bind(&DatabaseMessageFilter::RemoveObserver, this)); 56 base::Bind(&DatabaseMessageFilter::RemoveObserver, this));
57 } 57 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // SQLITE_OPEN_DELETEONCLOSE flag when opening all files, and keep 128 // SQLITE_OPEN_DELETEONCLOSE flag when opening all files, and keep
129 // open handles to them in the database tracker to make sure they're 129 // open handles to them in the database tracker to make sure they're
130 // around for as long as needed. 130 // around for as long as needed.
131 if (vfs_file_name.empty()) { 131 if (vfs_file_name.empty()) {
132 VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(), 132 VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(),
133 desired_flags, &file_handle); 133 desired_flags, &file_handle);
134 } else if (DatabaseUtil::CrackVfsFileName(vfs_file_name, &origin_identifier, 134 } else if (DatabaseUtil::CrackVfsFileName(vfs_file_name, &origin_identifier,
135 &database_name, NULL) && 135 &database_name, NULL) &&
136 !db_tracker_->IsDatabaseScheduledForDeletion(origin_identifier, 136 !db_tracker_->IsDatabaseScheduledForDeletion(origin_identifier,
137 database_name)) { 137 database_name)) {
138 base::FilePath db_file = 138 base::FilePath db_file = DatabaseUtil::GetFullFilePathForVfsFile(
139 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); 139 db_tracker_.get(), vfs_file_name);
140 if (!db_file.empty()) { 140 if (!db_file.empty()) {
141 if (db_tracker_->IsIncognitoProfile()) { 141 if (db_tracker_->IsIncognitoProfile()) {
142 db_tracker_->GetIncognitoFileHandle(vfs_file_name, &file_handle); 142 db_tracker_->GetIncognitoFileHandle(vfs_file_name, &file_handle);
143 if (file_handle == base::kInvalidPlatformFileValue) { 143 if (file_handle == base::kInvalidPlatformFileValue) {
144 VfsBackend::OpenFile(db_file, 144 VfsBackend::OpenFile(db_file,
145 desired_flags | SQLITE_OPEN_DELETEONCLOSE, 145 desired_flags | SQLITE_OPEN_DELETEONCLOSE,
146 &file_handle); 146 &file_handle);
147 if (!(desired_flags & SQLITE_OPEN_DELETEONCLOSE)) 147 if (!(desired_flags & SQLITE_OPEN_DELETEONCLOSE))
148 db_tracker_->SaveIncognitoFileHandle(vfs_file_name, file_handle); 148 db_tracker_->SaveIncognitoFileHandle(vfs_file_name, file_handle);
149 } 149 }
150 } else { 150 } else {
(...skipping 22 matching lines...) Expand all
173 void DatabaseMessageFilter::DatabaseDeleteFile(const string16& vfs_file_name, 173 void DatabaseMessageFilter::DatabaseDeleteFile(const string16& vfs_file_name,
174 bool sync_dir, 174 bool sync_dir,
175 IPC::Message* reply_msg, 175 IPC::Message* reply_msg,
176 int reschedule_count) { 176 int reschedule_count) {
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
178 178
179 // Return an error if the file name is invalid or if the file could not 179 // Return an error if the file name is invalid or if the file could not
180 // be deleted after kNumDeleteRetries attempts. 180 // be deleted after kNumDeleteRetries attempts.
181 int error_code = SQLITE_IOERR_DELETE; 181 int error_code = SQLITE_IOERR_DELETE;
182 base::FilePath db_file = 182 base::FilePath db_file =
183 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); 183 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_.get(), vfs_file_name);
184 if (!db_file.empty()) { 184 if (!db_file.empty()) {
185 // In order to delete a journal file in incognito mode, we only need to 185 // In order to delete a journal file in incognito mode, we only need to
186 // close the open handle to it that's stored in the database tracker. 186 // close the open handle to it that's stored in the database tracker.
187 if (db_tracker_->IsIncognitoProfile()) { 187 if (db_tracker_->IsIncognitoProfile()) {
188 const string16 wal_suffix(ASCIIToUTF16("-wal")); 188 const string16 wal_suffix(ASCIIToUTF16("-wal"));
189 string16 sqlite_suffix; 189 string16 sqlite_suffix;
190 190
191 // WAL files can be deleted without having previously been opened. 191 // WAL files can be deleted without having previously been opened.
192 if (!db_tracker_->HasSavedIncognitoFileHandle(vfs_file_name) && 192 if (!db_tracker_->HasSavedIncognitoFileHandle(vfs_file_name) &&
193 DatabaseUtil::CrackVfsFileName(vfs_file_name, 193 DatabaseUtil::CrackVfsFileName(vfs_file_name,
(...skipping 21 matching lines...) Expand all
215 DatabaseHostMsg_DeleteFile::WriteReplyParams(reply_msg, error_code); 215 DatabaseHostMsg_DeleteFile::WriteReplyParams(reply_msg, error_code);
216 Send(reply_msg); 216 Send(reply_msg);
217 } 217 }
218 218
219 void DatabaseMessageFilter::OnDatabaseGetFileAttributes( 219 void DatabaseMessageFilter::OnDatabaseGetFileAttributes(
220 const string16& vfs_file_name, 220 const string16& vfs_file_name,
221 IPC::Message* reply_msg) { 221 IPC::Message* reply_msg) {
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
223 int32 attributes = -1; 223 int32 attributes = -1;
224 base::FilePath db_file = 224 base::FilePath db_file =
225 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); 225 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_.get(), vfs_file_name);
226 if (!db_file.empty()) 226 if (!db_file.empty())
227 attributes = VfsBackend::GetFileAttributes(db_file); 227 attributes = VfsBackend::GetFileAttributes(db_file);
228 228
229 DatabaseHostMsg_GetFileAttributes::WriteReplyParams( 229 DatabaseHostMsg_GetFileAttributes::WriteReplyParams(
230 reply_msg, attributes); 230 reply_msg, attributes);
231 Send(reply_msg); 231 Send(reply_msg);
232 } 232 }
233 233
234 void DatabaseMessageFilter::OnDatabaseGetFileSize( 234 void DatabaseMessageFilter::OnDatabaseGetFileSize(
235 const string16& vfs_file_name, IPC::Message* reply_msg) { 235 const string16& vfs_file_name, IPC::Message* reply_msg) {
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
237 int64 size = 0; 237 int64 size = 0;
238 base::FilePath db_file = 238 base::FilePath db_file =
239 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); 239 DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_.get(), vfs_file_name);
240 if (!db_file.empty()) 240 if (!db_file.empty())
241 size = VfsBackend::GetFileSize(db_file); 241 size = VfsBackend::GetFileSize(db_file);
242 242
243 DatabaseHostMsg_GetFileSize::WriteReplyParams(reply_msg, size); 243 DatabaseHostMsg_GetFileSize::WriteReplyParams(reply_msg, size);
244 Send(reply_msg); 244 Send(reply_msg);
245 } 245 }
246 246
247 void DatabaseMessageFilter::OnDatabaseGetSpaceAvailable( 247 void DatabaseMessageFilter::OnDatabaseGetSpaceAvailable(
248 const string16& origin_identifier, IPC::Message* reply_msg) { 248 const string16& origin_identifier, IPC::Message* reply_msg) {
249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 void DatabaseMessageFilter::OnDatabaseScheduledForDeletion( 354 void DatabaseMessageFilter::OnDatabaseScheduledForDeletion(
355 const string16& origin_identifier, 355 const string16& origin_identifier,
356 const string16& database_name) { 356 const string16& database_name) {
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
358 Send(new DatabaseMsg_CloseImmediately(origin_identifier, database_name)); 358 Send(new DatabaseMsg_CloseImmediately(origin_identifier, database_name));
359 } 359 }
360 360
361 } // namespace content 361 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.cc ('k') | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698