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

Side by Side Diff: webkit/browser/fileapi/file_system_operation_runner.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/file_system_operation_runner.h" 5 #include "webkit/browser/fileapi/file_system_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
11 #include "webkit/browser/blob/blob_url_request_job_factory.h" 11 #include "webkit/browser/blob/blob_url_request_job_factory.h"
12 #include "webkit/browser/fileapi/file_observers.h" 12 #include "webkit/browser/fileapi/file_observers.h"
13 #include "webkit/browser/fileapi/file_stream_writer.h" 13 #include "webkit/browser/fileapi/file_stream_writer.h"
14 #include "webkit/browser/fileapi/file_system_context.h" 14 #include "webkit/browser/fileapi/file_system_context.h"
15 #include "webkit/browser/fileapi/file_system_operation.h" 15 #include "webkit/browser/fileapi/file_system_operation.h"
16 #include "webkit/browser/fileapi/file_writer_delegate.h" 16 #include "webkit/browser/fileapi/file_writer_delegate.h"
17 #include "webkit/common/blob/shareable_file_reference.h" 17 #include "webkit/common/blob/shareable_file_reference.h"
18 18
19 namespace fileapi { 19 namespace storage {
20 20
21 typedef FileSystemOperationRunner::OperationID OperationID; 21 typedef FileSystemOperationRunner::OperationID OperationID;
22 22
23 class FileSystemOperationRunner::BeginOperationScoper 23 class FileSystemOperationRunner::BeginOperationScoper
24 : public base::SupportsWeakPtr< 24 : public base::SupportsWeakPtr<
25 FileSystemOperationRunner::BeginOperationScoper> { 25 FileSystemOperationRunner::BeginOperationScoper> {
26 public: 26 public:
27 BeginOperationScoper() {} 27 BeginOperationScoper() {}
28 private: 28 private:
29 DISALLOW_COPY_AND_ASSIGN(BeginOperationScoper); 29 DISALLOW_COPY_AND_ASSIGN(BeginOperationScoper);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 operation->Remove( 231 operation->Remove(
232 url, recursive, 232 url, recursive,
233 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 233 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
234 handle, callback)); 234 handle, callback));
235 return handle.id; 235 return handle.id;
236 } 236 }
237 237
238 OperationID FileSystemOperationRunner::Write( 238 OperationID FileSystemOperationRunner::Write(
239 const net::URLRequestContext* url_request_context, 239 const net::URLRequestContext* url_request_context,
240 const FileSystemURL& url, 240 const FileSystemURL& url,
241 scoped_ptr<webkit_blob::BlobDataHandle> blob, 241 scoped_ptr<storage::BlobDataHandle> blob,
242 int64 offset, 242 int64 offset,
243 const WriteCallback& callback) { 243 const WriteCallback& callback) {
244 base::File::Error error = base::File::FILE_OK; 244 base::File::Error error = base::File::FILE_OK;
245 FileSystemOperation* operation = 245 FileSystemOperation* operation =
246 file_system_context_->CreateFileSystemOperation(url, &error); 246 file_system_context_->CreateFileSystemOperation(url, &error);
247 247
248 BeginOperationScoper scope; 248 BeginOperationScoper scope;
249 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 249 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
250 if (!operation) { 250 if (!operation) {
251 DidWrite(handle, callback, error, 0, true); 251 DidWrite(handle, callback, error, 0, true);
252 return handle.id; 252 return handle.id;
253 } 253 }
254 254
255 scoped_ptr<FileStreamWriter> writer( 255 scoped_ptr<FileStreamWriter> writer(
256 file_system_context_->CreateFileStreamWriter(url, offset)); 256 file_system_context_->CreateFileStreamWriter(url, offset));
257 if (!writer) { 257 if (!writer) {
258 // Write is not supported. 258 // Write is not supported.
259 DidWrite(handle, callback, base::File::FILE_ERROR_SECURITY, 0, true); 259 DidWrite(handle, callback, base::File::FILE_ERROR_SECURITY, 0, true);
260 return handle.id; 260 return handle.id;
261 } 261 }
262 262
263 FileWriterDelegate::FlushPolicy flush_policy = 263 FileWriterDelegate::FlushPolicy flush_policy =
264 file_system_context_->ShouldFlushOnWriteCompletion(url.type()) 264 file_system_context_->ShouldFlushOnWriteCompletion(url.type())
265 ? FileWriterDelegate::FLUSH_ON_COMPLETION 265 ? FileWriterDelegate::FLUSH_ON_COMPLETION
266 : FileWriterDelegate::NO_FLUSH_ON_COMPLETION; 266 : FileWriterDelegate::NO_FLUSH_ON_COMPLETION;
267 scoped_ptr<FileWriterDelegate> writer_delegate( 267 scoped_ptr<FileWriterDelegate> writer_delegate(
268 new FileWriterDelegate(writer.Pass(), flush_policy)); 268 new FileWriterDelegate(writer.Pass(), flush_policy));
269 269
270 scoped_ptr<net::URLRequest> blob_request( 270 scoped_ptr<net::URLRequest> blob_request(
271 webkit_blob::BlobProtocolHandler::CreateBlobRequest( 271 storage::BlobProtocolHandler::CreateBlobRequest(
272 blob.Pass(), 272 blob.Pass(), url_request_context, writer_delegate.get()));
273 url_request_context,
274 writer_delegate.get()));
275 273
276 PrepareForWrite(handle.id, url); 274 PrepareForWrite(handle.id, url);
277 operation->Write( 275 operation->Write(
278 url, writer_delegate.Pass(), blob_request.Pass(), 276 url, writer_delegate.Pass(), blob_request.Pass(),
279 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(), 277 base::Bind(&FileSystemOperationRunner::DidWrite, AsWeakPtr(),
280 handle, callback)); 278 handle, callback));
281 return handle.id; 279 return handle.id;
282 } 280 }
283 281
284 OperationID FileSystemOperationRunner::Truncate( 282 OperationID FileSystemOperationRunner::Truncate(
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 callback.Run(file.Pass(), on_close_callback); 589 callback.Run(file.Pass(), on_close_callback);
592 FinishOperation(handle.id); 590 FinishOperation(handle.id);
593 } 591 }
594 592
595 void FileSystemOperationRunner::DidCreateSnapshot( 593 void FileSystemOperationRunner::DidCreateSnapshot(
596 const OperationHandle& handle, 594 const OperationHandle& handle,
597 const SnapshotFileCallback& callback, 595 const SnapshotFileCallback& callback,
598 base::File::Error rv, 596 base::File::Error rv,
599 const base::File::Info& file_info, 597 const base::File::Info& file_info,
600 const base::FilePath& platform_path, 598 const base::FilePath& platform_path,
601 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 599 const scoped_refptr<storage::ShareableFileReference>& file_ref) {
602 if (handle.scope) { 600 if (handle.scope) {
603 finished_operations_.insert(handle.id); 601 finished_operations_.insert(handle.id);
604 base::MessageLoopProxy::current()->PostTask( 602 base::MessageLoopProxy::current()->PostTask(
605 FROM_HERE, base::Bind(&FileSystemOperationRunner::DidCreateSnapshot, 603 FROM_HERE, base::Bind(&FileSystemOperationRunner::DidCreateSnapshot,
606 AsWeakPtr(), handle, callback, rv, file_info, 604 AsWeakPtr(), handle, callback, rv, file_info,
607 platform_path, file_ref)); 605 platform_path, file_ref));
608 return; 606 return;
609 } 607 }
610 callback.Run(rv, file_info, platform_path, file_ref); 608 callback.Run(rv, file_info, platform_path, file_ref);
611 FinishOperation(handle.id); 609 FinishOperation(handle.id);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 std::map<OperationID, StatusCallback>::iterator found_cancel = 677 std::map<OperationID, StatusCallback>::iterator found_cancel =
680 stray_cancel_callbacks_.find(id); 678 stray_cancel_callbacks_.find(id);
681 if (found_cancel != stray_cancel_callbacks_.end()) { 679 if (found_cancel != stray_cancel_callbacks_.end()) {
682 // This cancel has been requested after the operation has finished, 680 // This cancel has been requested after the operation has finished,
683 // so report that we failed to stop it. 681 // so report that we failed to stop it.
684 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); 682 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION);
685 stray_cancel_callbacks_.erase(found_cancel); 683 stray_cancel_callbacks_.erase(found_cancel);
686 } 684 }
687 } 685 }
688 686
689 } // namespace fileapi 687 } // namespace storage
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_system_operation_runner.h ('k') | webkit/browser/fileapi/file_system_options.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698