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

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

Issue 7044095: Hooking MHTML generation to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 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
« no previous file with comments | « chrome/test/testing_browser_process.cc ('k') | content/common/notification_type.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/platform_file.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "content/browser/user_metrics.h" 13 #include "content/browser/user_metrics.h"
13 #include "content/common/database_messages.h" 14 #include "content/common/database_messages.h"
14 #include "content/common/result_codes.h" 15 #include "content/common/result_codes.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #include "third_party/sqlite/sqlite3.h" 17 #include "third_party/sqlite/sqlite3.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
18 #include "webkit/database/database_util.h" 19 #include "webkit/database/database_util.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 DatabaseMessageFilter::~DatabaseMessageFilter() { 139 DatabaseMessageFilter::~DatabaseMessageFilter() {
139 } 140 }
140 141
141 void DatabaseMessageFilter::OnDatabaseOpenFile(const string16& vfs_file_name, 142 void DatabaseMessageFilter::OnDatabaseOpenFile(const string16& vfs_file_name,
142 int desired_flags, 143 int desired_flags,
143 IPC::Message* reply_msg) { 144 IPC::Message* reply_msg) {
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
145 base::PlatformFile file_handle = base::kInvalidPlatformFileValue; 146 base::PlatformFile file_handle = base::kInvalidPlatformFileValue;
146 base::PlatformFile target_handle = base::kInvalidPlatformFileValue; 147 IPC::PlatformFileForTransit target_handle =
148 IPC::InvalidPlatformFileForTransit();
147 string16 origin_identifier; 149 string16 origin_identifier;
148 string16 database_name; 150 string16 database_name;
149 151
150 // When in incognito mode, we want to make sure that all DB files are 152 // When in incognito mode, we want to make sure that all DB files are
151 // removed when the incognito profile goes away, so we add the 153 // removed when the incognito profile goes away, so we add the
152 // SQLITE_OPEN_DELETEONCLOSE flag when opening all files, and keep 154 // SQLITE_OPEN_DELETEONCLOSE flag when opening all files, and keep
153 // open handles to them in the database tracker to make sure they're 155 // open handles to them in the database tracker to make sure they're
154 // around for as long as needed. 156 // around for as long as needed.
155 if (vfs_file_name.empty()) { 157 if (vfs_file_name.empty()) {
156 VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(), 158 VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(),
(...skipping 18 matching lines...) Expand all
175 } else { 177 } else {
176 VfsBackend::OpenFile(db_file, desired_flags, &file_handle); 178 VfsBackend::OpenFile(db_file, desired_flags, &file_handle);
177 } 179 }
178 } 180 }
179 } 181 }
180 182
181 // Then we duplicate the file handle to make it useable in the renderer 183 // Then we duplicate the file handle to make it useable in the renderer
182 // process. The original handle is closed, unless we saved it in the 184 // process. The original handle is closed, unless we saved it in the
183 // database tracker. 185 // database tracker.
184 bool auto_close = !db_tracker_->HasSavedIncognitoFileHandle(vfs_file_name); 186 bool auto_close = !db_tracker_->HasSavedIncognitoFileHandle(vfs_file_name);
185 VfsBackend::GetFileHandleForProcess(peer_handle(), file_handle, 187 target_handle =
186 &target_handle, auto_close); 188 IPC::GetFileHandleForProcess(file_handle, peer_handle(), auto_close);
187 189
188 DatabaseHostMsg_OpenFile::WriteReplyParams( 190 DatabaseHostMsg_OpenFile::WriteReplyParams(reply_msg, target_handle);
189 reply_msg,
190 #if defined(OS_WIN)
191 target_handle
192 #elif defined(OS_POSIX)
193 base::FileDescriptor(target_handle, auto_close)
194 #endif
195 );
196 Send(reply_msg); 191 Send(reply_msg);
197 } 192 }
198 193
199 void DatabaseMessageFilter::OnDatabaseDeleteFile(const string16& vfs_file_name, 194 void DatabaseMessageFilter::OnDatabaseDeleteFile(const string16& vfs_file_name,
200 const bool& sync_dir, 195 const bool& sync_dir,
201 IPC::Message* reply_msg) { 196 IPC::Message* reply_msg) {
202 DatabaseDeleteFile(vfs_file_name, sync_dir, reply_msg, kNumDeleteRetries); 197 DatabaseDeleteFile(vfs_file_name, sync_dir, reply_msg, kNumDeleteRetries);
203 } 198 }
204 199
205 void DatabaseMessageFilter::DatabaseDeleteFile(const string16& vfs_file_name, 200 void DatabaseMessageFilter::DatabaseDeleteFile(const string16& vfs_file_name,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 database_size)); 347 database_size));
353 } 348 }
354 } 349 }
355 350
356 void DatabaseMessageFilter::OnDatabaseScheduledForDeletion( 351 void DatabaseMessageFilter::OnDatabaseScheduledForDeletion(
357 const string16& origin_identifier, 352 const string16& origin_identifier,
358 const string16& database_name) { 353 const string16& database_name) {
359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
360 Send(new DatabaseMsg_CloseImmediately(origin_identifier, database_name)); 355 Send(new DatabaseMsg_CloseImmediately(origin_identifier, database_name));
361 } 356 }
OLDNEW
« no previous file with comments | « chrome/test/testing_browser_process.cc ('k') | content/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698