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

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

Issue 897563002: Unify the three places that patch font loading for PDFium on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread_local.h" 13 #include "base/threading/thread_local.h"
14 #include "content/child/child_thread.h" 14 #include "content/child/child_thread_impl.h"
15 #include "content/child/file_info_util.h" 15 #include "content/child/file_info_util.h"
16 #include "content/child/fileapi/file_system_dispatcher.h" 16 #include "content/child/fileapi/file_system_dispatcher.h"
17 #include "content/child/fileapi/webfilewriter_impl.h" 17 #include "content/child/fileapi/webfilewriter_impl.h"
18 #include "content/child/worker_task_runner.h" 18 #include "content/child/worker_task_runner.h"
19 #include "content/common/fileapi/file_system_messages.h" 19 #include "content/common/fileapi/file_system_messages.h"
20 #include "storage/common/fileapi/directory_entry.h" 20 #include "storage/common/fileapi/directory_entry.h"
21 #include "storage/common/fileapi/file_system_util.h" 21 #include "storage/common/fileapi/file_system_util.h"
22 #include "third_party/WebKit/public/platform/WebFileInfo.h" 22 #include "third_party/WebKit/public/platform/WebFileInfo.h"
23 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" 23 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h"
24 #include "third_party/WebKit/public/platform/WebString.h" 24 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 namespace { 81 namespace {
82 82
83 typedef WebFileSystemImpl::WaitableCallbackResults WaitableCallbackResults; 83 typedef WebFileSystemImpl::WaitableCallbackResults WaitableCallbackResults;
84 84
85 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky 85 base::LazyInstance<base::ThreadLocalPointer<WebFileSystemImpl> >::Leaky
86 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER; 86 g_webfilesystem_tls = LAZY_INSTANCE_INITIALIZER;
87 87
88 void DidReceiveSnapshotFile(int request_id) { 88 void DidReceiveSnapshotFile(int request_id) {
89 if (ChildThread::current()) 89 if (ChildThreadImpl::current())
90 ChildThread::current()->Send( 90 ChildThreadImpl::current()->Send(
91 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); 91 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id));
92 } 92 }
93 93
94 int CurrentWorkerId() { 94 int CurrentWorkerId() {
95 return WorkerTaskRunner::Instance()->CurrentWorkerId(); 95 return WorkerTaskRunner::Instance()->CurrentWorkerId();
96 } 96 }
97 97
98 template <typename Method, typename Params> 98 template <typename Method, typename Params>
99 void CallDispatcherOnMainThread( 99 void CallDispatcherOnMainThread(
100 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, 100 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner,
101 Method method, const Params& params, 101 Method method, const Params& params,
102 WaitableCallbackResults* waitable_results) { 102 WaitableCallbackResults* waitable_results) {
103 if (!main_thread_task_runner->RunsTasksOnCurrentThread()) { 103 if (!main_thread_task_runner->RunsTasksOnCurrentThread()) {
104 main_thread_task_runner->PostTask( 104 main_thread_task_runner->PostTask(
105 FROM_HERE, 105 FROM_HERE,
106 base::Bind(&CallDispatcherOnMainThread<Method, Params>, 106 base::Bind(&CallDispatcherOnMainThread<Method, Params>,
107 main_thread_task_runner, method, params, 107 main_thread_task_runner, method, params,
108 scoped_refptr<WaitableCallbackResults>())); 108 scoped_refptr<WaitableCallbackResults>()));
109 if (!waitable_results) 109 if (!waitable_results)
110 return; 110 return;
111 waitable_results->WaitAndRun(); 111 waitable_results->WaitAndRun();
112 } 112 }
113 if (!ChildThread::current() || 113 if (!ChildThreadImpl::current() ||
114 !ChildThread::current()->file_system_dispatcher()) 114 !ChildThreadImpl::current()->file_system_dispatcher())
115 return; 115 return;
116 116
117 DCHECK(!waitable_results); 117 DCHECK(!waitable_results);
118 DispatchToMethod(ChildThread::current()->file_system_dispatcher(), 118 DispatchToMethod(ChildThreadImpl::current()->file_system_dispatcher(),
119 method, params); 119 method, params);
120 } 120 }
121 121
122 enum CallbacksUnregisterMode { 122 enum CallbacksUnregisterMode {
123 UNREGISTER_CALLBACKS, 123 UNREGISTER_CALLBACKS,
124 DO_NOT_UNREGISTER_CALLBACKS, 124 DO_NOT_UNREGISTER_CALLBACKS,
125 }; 125 };
126 126
127 // Bridging functions that convert the arguments into Blink objects 127 // Bridging functions that convert the arguments into Blink objects
128 // (e.g. WebFileInfo, WebString, WebVector<WebFileSystemEntry>) 128 // (e.g. WebFileInfo, WebString, WebVector<WebFileSystemEntry>)
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults( 697 WaitableCallbackResults* WebFileSystemImpl::MaybeCreateWaitableResults(
698 const WebFileSystemCallbacks& callbacks, int callbacks_id) { 698 const WebFileSystemCallbacks& callbacks, int callbacks_id) {
699 if (!callbacks.shouldBlockUntilCompletion()) 699 if (!callbacks.shouldBlockUntilCompletion())
700 return NULL; 700 return NULL;
701 WaitableCallbackResults* results = new WaitableCallbackResults(); 701 WaitableCallbackResults* results = new WaitableCallbackResults();
702 waitable_results_[callbacks_id] = results; 702 waitable_results_[callbacks_id] = results;
703 return results; 703 return results;
704 } 704 }
705 705
706 } // namespace content 706 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698