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

Side by Side Diff: content/child/fileapi/webfilesystem_impl.cc

Issue 22363002: 2nd try: Support synchronous mode in WebFileWriterImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « no previous file | content/child/fileapi/webfilewriter_impl.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 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 "content/child/fileapi/webfilesystem_impl.h" 5 #include "content/child/fileapi/webfilesystem_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/id_map.h" 8 #include "base/id_map.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return; 245 return;
246 246
247 WebFileSystemCallbacks* callbacks = 247 WebFileSystemCallbacks* callbacks =
248 CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id); 248 CallbacksMap::Get()->GetAndUnregisterCallbacks(callbacks_id);
249 DCHECK(callbacks); 249 DCHECK(callbacks);
250 250
251 if (file_info.is_directory || file_info.size < 0) { 251 if (file_info.is_directory || file_info.size < 0) {
252 callbacks->didFail(WebKit::WebFileErrorInvalidState); 252 callbacks->didFail(WebKit::WebFileErrorInvalidState);
253 return; 253 return;
254 } 254 }
255 WebFileWriterImpl::Type type = callbacks->shouldBlockUntilCompletion() ?
256 WebFileWriterImpl::TYPE_SYNC : WebFileWriterImpl::TYPE_ASYNC;
255 callbacks->didCreateFileWriter( 257 callbacks->didCreateFileWriter(
256 new WebFileWriterImpl(path, client, main_thread_loop), file_info.size); 258 new WebFileWriterImpl(path, client, type, main_thread_loop),
259 file_info.size);
257 } 260 }
258 261
259 void CreateFileWriterCallbackAdapter( 262 void CreateFileWriterCallbackAdapter(
260 int thread_id, int callbacks_id, 263 int thread_id, int callbacks_id,
261 WaitableCallbackResults* waitable_results, 264 WaitableCallbackResults* waitable_results,
262 base::MessageLoopProxy* main_thread_loop, 265 base::MessageLoopProxy* main_thread_loop,
263 const GURL& path, 266 const GURL& path,
264 WebKit::WebFileWriterClient* client, 267 WebKit::WebFileWriterClient* client,
265 const base::PlatformFileInfo& file_info) { 268 const base::PlatformFileInfo& file_info) {
266 DispatchResultsClosure( 269 DispatchResultsClosure(
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 CurrentWorkerId(), callbacks_id, 484 CurrentWorkerId(), callbacks_id,
482 base::Unretained(waitable_results)), 485 base::Unretained(waitable_results)),
483 base::Bind(&StatusCallbackAdapter, 486 base::Bind(&StatusCallbackAdapter,
484 CurrentWorkerId(), callbacks_id, 487 CurrentWorkerId(), callbacks_id,
485 base::Unretained(waitable_results))), 488 base::Unretained(waitable_results))),
486 make_scoped_ptr(waitable_results)); 489 make_scoped_ptr(waitable_results));
487 } 490 }
488 491
489 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( 492 WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter(
490 const WebURL& path, WebKit::WebFileWriterClient* client) { 493 const WebURL& path, WebKit::WebFileWriterClient* client) {
491 return new WebFileWriterImpl(GURL(path), client, main_thread_loop_.get()); 494 return new WebFileWriterImpl(GURL(path), client,
495 WebFileWriterImpl::TYPE_ASYNC,
496 main_thread_loop_.get());
492 } 497 }
493 498
494 void WebFileSystemImpl::createFileWriter( 499 void WebFileSystemImpl::createFileWriter(
495 const WebURL& path, 500 const WebURL& path,
496 WebKit::WebFileWriterClient* client, 501 WebKit::WebFileWriterClient* client,
497 WebKit::WebFileSystemCallbacks* callbacks) { 502 WebKit::WebFileSystemCallbacks* callbacks) {
498 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks); 503 int callbacks_id = CallbacksMap::GetOrCreate()->RegisterCallbacks(callbacks);
499 WaitableCallbackResults* waitable_results = 504 WaitableCallbackResults* waitable_results =
500 WaitableCallbackResults::MaybeCreate(callbacks); 505 WaitableCallbackResults::MaybeCreate(callbacks);
501 CallDispatcherOnMainThread( 506 CallDispatcherOnMainThread(
(...skipping 24 matching lines...) Expand all
526 CurrentWorkerId(), callbacks_id, 531 CurrentWorkerId(), callbacks_id,
527 base::Unretained(waitable_results), 532 base::Unretained(waitable_results),
528 main_thread_loop_), 533 main_thread_loop_),
529 base::Bind(&StatusCallbackAdapter, 534 base::Bind(&StatusCallbackAdapter,
530 CurrentWorkerId(), callbacks_id, 535 CurrentWorkerId(), callbacks_id,
531 base::Unretained(waitable_results))), 536 base::Unretained(waitable_results))),
532 make_scoped_ptr(waitable_results)); 537 make_scoped_ptr(waitable_results));
533 } 538 }
534 539
535 } // namespace content 540 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/fileapi/webfilewriter_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698