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

Side by Side Diff: content/browser/file_system/file_system_dispatcher_host.cc

Issue 7618039: PPB_URLRequestInfo::AppendFileToBody using sync ipc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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) 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/file_system/file_system_dispatcher_host.h" 5 #include "content/browser/file_system/file_system_dispatcher_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "content/browser/resource_context.h" 14 #include "content/browser/resource_context.h"
15 #include "content/common/file_system_messages.h" 15 #include "content/common/file_system_messages.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "ipc/ipc_platform_file.h" 17 #include "ipc/ipc_platform_file.h"
18 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
19 #include "webkit/fileapi/file_system_callback_dispatcher.h" 19 #include "webkit/fileapi/file_system_callback_dispatcher.h"
20 #include "webkit/fileapi/file_system_context.h" 20 #include "webkit/fileapi/file_system_context.h"
21 #include "webkit/fileapi/file_system_operation.h" 21 #include "webkit/fileapi/file_system_operation.h"
22 #include "webkit/fileapi/file_system_operation.h" 22 #include "webkit/fileapi/file_system_operation.h"
23 #include "webkit/fileapi/file_system_path_manager.h" 23 #include "webkit/fileapi/file_system_path_manager.h"
24 #include "webkit/fileapi/file_system_quota_util.h" 24 #include "webkit/fileapi/file_system_quota_util.h"
25 #include "webkit/fileapi/file_system_util.h" 25 #include "webkit/fileapi/file_system_util.h"
26 26
27 using fileapi::FileSystemCallbackDispatcher; 27 using fileapi::FileSystemCallbackDispatcher;
28 using fileapi::FileSystemFileUtil;
28 using fileapi::FileSystemOperation; 29 using fileapi::FileSystemOperation;
30 using fileapi::FileSystemOperationContext;
29 31
30 class BrowserFileSystemCallbackDispatcher 32 class BrowserFileSystemCallbackDispatcher
31 : public FileSystemCallbackDispatcher { 33 : public FileSystemCallbackDispatcher {
32 public: 34 public:
33 BrowserFileSystemCallbackDispatcher( 35 BrowserFileSystemCallbackDispatcher(
34 FileSystemDispatcherHost* dispatcher_host, int request_id) 36 FileSystemDispatcherHost* dispatcher_host, int request_id)
35 : dispatcher_host_(dispatcher_host), 37 : dispatcher_host_(dispatcher_host),
36 request_id_(request_id) { 38 request_id_(request_id) {
37 DCHECK(dispatcher_host_); 39 DCHECK(dispatcher_host_);
38 } 40 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(!request_context_); 121 DCHECK(!request_context_);
120 request_context_ = resource_context_->request_context(); 122 request_context_ = resource_context_->request_context();
121 DCHECK(!context_); 123 DCHECK(!context_);
122 context_ = resource_context_->file_system_context(); 124 context_ = resource_context_->file_system_context();
123 resource_context_ = NULL; 125 resource_context_ = NULL;
124 } 126 }
125 DCHECK(request_context_); 127 DCHECK(request_context_);
126 DCHECK(context_); 128 DCHECK(context_);
127 } 129 }
128 130
131 void FileSystemDispatcherHost::OverrideThreadForMessage(
132 const IPC::Message& message,
133 BrowserThread::ID* thread) {
134 if (message.type() == FileSystemHostMsg_SyncGetPlatformPath::ID)
135 *thread = BrowserThread::FILE;
136 }
137
129 bool FileSystemDispatcherHost::OnMessageReceived( 138 bool FileSystemDispatcherHost::OnMessageReceived(
130 const IPC::Message& message, bool* message_was_ok) { 139 const IPC::Message& message, bool* message_was_ok) {
131 *message_was_ok = true; 140 *message_was_ok = true;
132 bool handled = true; 141 bool handled = true;
133 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok) 142 IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok)
134 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Open, OnOpen) 143 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Open, OnOpen)
135 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Move, OnMove) 144 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Move, OnMove)
136 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Copy, OnCopy) 145 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Copy, OnCopy)
137 IPC_MESSAGE_HANDLER(FileSystemMsg_Remove, OnRemove) 146 IPC_MESSAGE_HANDLER(FileSystemMsg_Remove, OnRemove)
138 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadMetadata, OnReadMetadata) 147 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadMetadata, OnReadMetadata)
139 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Create, OnCreate) 148 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Create, OnCreate)
140 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Exists, OnExists) 149 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Exists, OnExists)
141 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadDirectory, OnReadDirectory) 150 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadDirectory, OnReadDirectory)
142 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Write, OnWrite) 151 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Write, OnWrite)
143 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Truncate, OnTruncate) 152 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Truncate, OnTruncate)
144 IPC_MESSAGE_HANDLER(FileSystemHostMsg_TouchFile, OnTouchFile) 153 IPC_MESSAGE_HANDLER(FileSystemHostMsg_TouchFile, OnTouchFile)
145 IPC_MESSAGE_HANDLER(FileSystemHostMsg_CancelWrite, OnCancel) 154 IPC_MESSAGE_HANDLER(FileSystemHostMsg_CancelWrite, OnCancel)
146 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFile, OnOpenFile) 155 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFile, OnOpenFile)
147 IPC_MESSAGE_HANDLER(FileSystemHostMsg_WillUpdate, OnWillUpdate) 156 IPC_MESSAGE_HANDLER(FileSystemHostMsg_WillUpdate, OnWillUpdate)
148 IPC_MESSAGE_HANDLER(FileSystemHostMsg_DidUpdate, OnDidUpdate) 157 IPC_MESSAGE_HANDLER(FileSystemHostMsg_DidUpdate, OnDidUpdate)
158 IPC_MESSAGE_HANDLER(FileSystemHostMsg_SyncGetPlatformPath,
159 OnSyncGetPlatformPath)
149 IPC_MESSAGE_UNHANDLED(handled = false) 160 IPC_MESSAGE_UNHANDLED(handled = false)
150 IPC_END_MESSAGE_MAP_EX() 161 IPC_END_MESSAGE_MAP_EX()
151 return handled; 162 return handled;
152 } 163 }
153 164
154 void FileSystemDispatcherHost::OnOpen( 165 void FileSystemDispatcherHost::OnOpen(
155 int request_id, const GURL& origin_url, fileapi::FileSystemType type, 166 int request_id, const GURL& origin_url, fileapi::FileSystemType type,
156 int64 requested_size, bool create) { 167 int64 requested_size, bool create) {
157 GetNewOperation(request_id)->OpenFileSystem(origin_url, type, create); 168 GetNewOperation(request_id)->OpenFileSystem(origin_url, type, create);
158 } 169 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if (!CrackFileSystemURL(path, &origin_url, &type, NULL)) 273 if (!CrackFileSystemURL(path, &origin_url, &type, NULL))
263 return; 274 return;
264 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type); 275 fileapi::FileSystemQuotaUtil* quota_util = context_->GetQuotaUtil(type);
265 if (!quota_util) 276 if (!quota_util)
266 return; 277 return;
267 quota_util->proxy()->UpdateOriginUsage( 278 quota_util->proxy()->UpdateOriginUsage(
268 context_->quota_manager_proxy(), origin_url, type, delta); 279 context_->quota_manager_proxy(), origin_url, type, delta);
269 quota_util->proxy()->EndUpdateOrigin(origin_url, type); 280 quota_util->proxy()->EndUpdateOrigin(origin_url, type);
270 } 281 }
271 282
283 void FileSystemDispatcherHost::OnSyncGetPlatformPath(
284 const GURL& path, FilePath* platform_path) {
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
286 DCHECK(platform_path);
287 *platform_path = FilePath();
288 base::PlatformFileInfo info;
289 GURL origin_url;
290 fileapi::FileSystemType type;
291 FilePath virtual_path;
292 if (!CrackFileSystemURL(path, &origin_url, &type, &virtual_path))
293 return;
294 FileSystemFileUtil* file_util =
295 context_->path_manager()->GetFileSystemFileUtil(type);
296 if (!file_util)
297 return;
298 FileSystemOperationContext operation_context(context_, file_util);
299 operation_context.set_src_origin_url(origin_url);
300 operation_context.set_src_type(type);
301 file_util->GetFileInfo(&operation_context, virtual_path,
302 &info, platform_path);
303 }
304
272 FileSystemOperation* FileSystemDispatcherHost::GetNewOperation( 305 FileSystemOperation* FileSystemDispatcherHost::GetNewOperation(
273 int request_id) { 306 int request_id) {
274 BrowserFileSystemCallbackDispatcher* dispatcher = 307 BrowserFileSystemCallbackDispatcher* dispatcher =
275 new BrowserFileSystemCallbackDispatcher(this, request_id); 308 new BrowserFileSystemCallbackDispatcher(this, request_id);
276 FileSystemOperation* operation = new FileSystemOperation( 309 FileSystemOperation* operation = new FileSystemOperation(
277 dispatcher, 310 dispatcher,
278 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 311 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
279 context_, 312 context_,
280 NULL); 313 NULL);
281 operations_.AddWithID(operation, request_id); 314 operations_.AddWithID(operation, request_id);
282 return operation; 315 return operation;
283 } 316 }
284 317
285 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { 318 void FileSystemDispatcherHost::UnregisterOperation(int request_id) {
286 DCHECK(operations_.Lookup(request_id)); 319 DCHECK(operations_.Lookup(request_id));
287 operations_.Remove(request_id); 320 operations_.Remove(request_id);
288 } 321 }
OLDNEW
« no previous file with comments | « content/browser/file_system/file_system_dispatcher_host.h ('k') | content/common/file_system_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698