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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup around ValidateFileSystemRoot 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/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"
(...skipping 12 matching lines...) Expand all
23 #include "webkit/fileapi/file_system_operation.h" 23 #include "webkit/fileapi/file_system_operation.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 content::BrowserMessageFilter; 27 using content::BrowserMessageFilter;
28 using content::BrowserThread; 28 using content::BrowserThread;
29 using content::UserMetricsAction; 29 using content::UserMetricsAction;
30 using fileapi::FileSystemCallbackDispatcher; 30 using fileapi::FileSystemCallbackDispatcher;
31 using fileapi::FileSystemFileUtil; 31 using fileapi::FileSystemFileUtil;
32 using fileapi::FileSystemOperation; 32 using fileapi::FileSystemOperation;
33 using fileapi::FileSystemOperationContext;
34 33
35 class BrowserFileSystemCallbackDispatcher 34 class BrowserFileSystemCallbackDispatcher
36 : public FileSystemCallbackDispatcher { 35 : public FileSystemCallbackDispatcher {
37 public: 36 public:
38 BrowserFileSystemCallbackDispatcher( 37 BrowserFileSystemCallbackDispatcher(
39 FileSystemDispatcherHost* dispatcher_host, int request_id) 38 FileSystemDispatcherHost* dispatcher_host, int request_id)
40 : dispatcher_host_(dispatcher_host), 39 : dispatcher_host_(dispatcher_host),
41 request_id_(request_id) { 40 request_id_(request_id) {
42 DCHECK(dispatcher_host_); 41 DCHECK(dispatcher_host_);
43 } 42 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 163 }
165 164
166 void FileSystemDispatcherHost::OnOpen( 165 void FileSystemDispatcherHost::OnOpen(
167 int request_id, const GURL& origin_url, fileapi::FileSystemType type, 166 int request_id, const GURL& origin_url, fileapi::FileSystemType type,
168 int64 requested_size, bool create) { 167 int64 requested_size, bool create) {
169 if (type == fileapi::kFileSystemTypeTemporary) { 168 if (type == fileapi::kFileSystemTypeTemporary) {
170 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary")); 169 content::RecordAction(UserMetricsAction("OpenFileSystemTemporary"));
171 } else if (type == fileapi::kFileSystemTypePersistent) { 170 } else if (type == fileapi::kFileSystemTypePersistent) {
172 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent")); 171 content::RecordAction(UserMetricsAction("OpenFileSystemPersistent"));
173 } 172 }
174 GetNewOperation(request_id)->OpenFileSystem(origin_url, type, create); 173 context_->OpenFileSystem(origin_url, type, create,
174 new BrowserFileSystemCallbackDispatcher(
175 this, request_id));
175 } 176 }
176 177
177 void FileSystemDispatcherHost::OnMove( 178 void FileSystemDispatcherHost::OnMove(
178 int request_id, const GURL& src_path, const GURL& dest_path) { 179 int request_id, const GURL& src_path, const GURL& dest_path) {
179 GetNewOperation(request_id)->Move(src_path, dest_path); 180 GetNewOperation(request_id)->Move(src_path, dest_path);
180 } 181 }
181 182
182 void FileSystemDispatcherHost::OnCopy( 183 void FileSystemDispatcherHost::OnCopy(
183 int request_id, const GURL& src_path, const GURL& dest_path) { 184 int request_id, const GURL& src_path, const GURL& dest_path) {
184 GetNewOperation(request_id)->Copy(src_path, dest_path); 185 GetNewOperation(request_id)->Copy(src_path, dest_path);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 248 }
248 249
249 void FileSystemDispatcherHost::OnCancel( 250 void FileSystemDispatcherHost::OnCancel(
250 int request_id, 251 int request_id,
251 int request_id_to_cancel) { 252 int request_id_to_cancel) {
252 FileSystemOperation* write = operations_.Lookup( 253 FileSystemOperation* write = operations_.Lookup(
253 request_id_to_cancel); 254 request_id_to_cancel);
254 if (write) { 255 if (write) {
255 // The cancel will eventually send both the write failure and the cancel 256 // The cancel will eventually send both the write failure and the cancel
256 // success. 257 // success.
257 write->Cancel(GetNewOperation(request_id)); 258 write->Cancel(new BrowserFileSystemCallbackDispatcher(this, request_id));
258 } else { 259 } else {
259 // The write already finished; report that we failed to stop it. 260 // The write already finished; report that we failed to stop it.
260 Send(new FileSystemMsg_DidFail( 261 Send(new FileSystemMsg_DidFail(
261 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); 262 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION));
262 } 263 }
263 } 264 }
264 265
265 void FileSystemDispatcherHost::OnOpenFile( 266 void FileSystemDispatcherHost::OnOpenFile(
266 int request_id, const GURL& path, int file_flags) { 267 int request_id, const GURL& path, int file_flags) {
267 GetNewOperation(request_id)->OpenFile(path, file_flags, peer_handle()); 268 GetNewOperation(request_id)->OpenFile(path, file_flags, peer_handle());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 new BrowserFileSystemCallbackDispatcher(this, request_id); 312 new BrowserFileSystemCallbackDispatcher(this, request_id);
312 FileSystemOperation* operation = new FileSystemOperation( 313 FileSystemOperation* operation = new FileSystemOperation(
313 dispatcher, 314 dispatcher,
314 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 315 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
315 context_); 316 context_);
316 operations_.AddWithID(operation, request_id); 317 operations_.AddWithID(operation, request_id);
317 return operation; 318 return operation;
318 } 319 }
319 320
320 void FileSystemDispatcherHost::UnregisterOperation(int request_id) { 321 void FileSystemDispatcherHost::UnregisterOperation(int request_id) {
321 DCHECK(operations_.Lookup(request_id));
322 operations_.Remove(request_id); 322 operations_.Remove(request_id);
323 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698