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

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

Issue 2916303002: ThreadChecker instead of SequenceChecker in classes that use TLS. (Closed)
Patch Set: fix compile Created 3 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
« no previous file with comments | « content/child/fileapi/webfilesystem_impl.h ('k') | no next file » | 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 <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (ChildThreadImpl::current()) 90 if (ChildThreadImpl::current())
91 ChildThreadImpl::current()->Send( 91 ChildThreadImpl::current()->Send(
92 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); 92 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id));
93 } 93 }
94 94
95 template <typename Method, typename Params> 95 template <typename Method, typename Params>
96 void CallDispatcherOnMainThread( 96 void CallDispatcherOnMainThread(
97 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, 97 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner,
98 Method method, const Params& params, 98 Method method, const Params& params,
99 WaitableCallbackResults* waitable_results) { 99 WaitableCallbackResults* waitable_results) {
100 if (!main_thread_task_runner->RunsTasksInCurrentSequence()) { 100 if (!main_thread_task_runner->BelongsToCurrentThread()) {
101 main_thread_task_runner->PostTask( 101 main_thread_task_runner->PostTask(
102 FROM_HERE, 102 FROM_HERE,
103 base::Bind(&CallDispatcherOnMainThread<Method, Params>, 103 base::Bind(&CallDispatcherOnMainThread<Method, Params>,
104 main_thread_task_runner, method, params, nullptr)); 104 main_thread_task_runner, method, params, nullptr));
105 if (!waitable_results) 105 if (!waitable_results)
106 return; 106 return;
107 waitable_results->WaitAndRun(); 107 waitable_results->WaitAndRun();
108 } 108 }
109 if (!ChildThreadImpl::current() || 109 if (!ChildThreadImpl::current() ||
110 !ChildThreadImpl::current()->file_system_dispatcher()) 110 !ChildThreadImpl::current()->file_system_dispatcher())
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 390 }
391 391
392 WebFileSystemImpl::WebFileSystemImpl( 392 WebFileSystemImpl::WebFileSystemImpl(
393 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner) 393 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner)
394 : main_thread_task_runner_(main_thread_task_runner), 394 : main_thread_task_runner_(main_thread_task_runner),
395 next_callbacks_id_(1) { 395 next_callbacks_id_(1) {
396 g_webfilesystem_tls.Pointer()->Set(this); 396 g_webfilesystem_tls.Pointer()->Set(this);
397 } 397 }
398 398
399 WebFileSystemImpl::~WebFileSystemImpl() { 399 WebFileSystemImpl::~WebFileSystemImpl() {
400 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 400 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
401 g_webfilesystem_tls.Pointer()->Set(NULL); 401 g_webfilesystem_tls.Pointer()->Set(NULL);
402 } 402 }
403 403
404 void WebFileSystemImpl::WillStopCurrentWorkerThread() { 404 void WebFileSystemImpl::WillStopCurrentWorkerThread() {
405 delete this; 405 delete this;
406 } 406 }
407 407
408 void WebFileSystemImpl::OpenFileSystem(const blink::WebURL& storage_partition, 408 void WebFileSystemImpl::OpenFileSystem(const blink::WebURL& storage_partition,
409 blink::WebFileSystemType type, 409 blink::WebFileSystemType type,
410 WebFileSystemCallbacks callbacks) { 410 WebFileSystemCallbacks callbacks) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 waitable_results_.find(callbacksId); 648 waitable_results_.find(callbacksId);
649 if (found == waitable_results_.end()) 649 if (found == waitable_results_.end())
650 return false; 650 return false;
651 651
652 found->second->WaitAndRun(); 652 found->second->WaitAndRun();
653 return true; 653 return true;
654 } 654 }
655 655
656 int WebFileSystemImpl::RegisterCallbacks( 656 int WebFileSystemImpl::RegisterCallbacks(
657 const WebFileSystemCallbacks& callbacks) { 657 const WebFileSystemCallbacks& callbacks) {
658 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 658 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
659 int id = next_callbacks_id_++; 659 int id = next_callbacks_id_++;
660 callbacks_[id] = callbacks; 660 callbacks_[id] = callbacks;
661 return id; 661 return id;
662 } 662 }
663 663
664 WebFileSystemCallbacks WebFileSystemImpl::GetCallbacks(int callbacks_id) { 664 WebFileSystemCallbacks WebFileSystemImpl::GetCallbacks(int callbacks_id) {
665 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 665 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
666 CallbacksMap::iterator found = callbacks_.find(callbacks_id); 666 CallbacksMap::iterator found = callbacks_.find(callbacks_id);
667 DCHECK(found != callbacks_.end()); 667 DCHECK(found != callbacks_.end());
668 return found->second; 668 return found->second;
669 } 669 }
670 670
671 void WebFileSystemImpl::UnregisterCallbacks(int callbacks_id) { 671 void WebFileSystemImpl::UnregisterCallbacks(int callbacks_id) {
672 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 672 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
673 CallbacksMap::iterator found = callbacks_.find(callbacks_id); 673 CallbacksMap::iterator found = callbacks_.find(callbacks_id);
674 DCHECK(found != callbacks_.end()); 674 DCHECK(found != callbacks_.end());
675 callbacks_.erase(found); 675 callbacks_.erase(found);
676 676
677 waitable_results_.erase(callbacks_id); 677 waitable_results_.erase(callbacks_id);
678 } 678 }
679 679
680 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults( 680 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults(
681 const WebFileSystemCallbacks& callbacks, int callbacks_id) { 681 const WebFileSystemCallbacks& callbacks, int callbacks_id) {
682 if (!callbacks.ShouldBlockUntilCompletion()) 682 if (!callbacks.ShouldBlockUntilCompletion())
683 return NULL; 683 return NULL;
684 WaitableCallbackResults* results = new WaitableCallbackResults(); 684 WaitableCallbackResults* results = new WaitableCallbackResults();
685 waitable_results_[callbacks_id] = results; 685 waitable_results_[callbacks_id] = results;
686 return results; 686 return results;
687 } 687 }
688 688
689 } // namespace content 689 } // namespace content
OLDNEW
« no previous file with comments | « content/child/fileapi/webfilesystem_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698