hunspell: Cleanup to fix the header include guards under google/ directory.
[chromium-blink-merge.git] / ios / web / web_thread_adapter.cc
blobc0be57c63c2a78bb35abae2c84b4c61f8673ab1a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/web/web_thread_adapter.h"
7 #include "content/public/browser/browser_thread.h"
9 namespace web {
11 namespace {
13 WebThread::ID WebThreadIDFromBrowserThreadID(
14 content::BrowserThread::ID identifier) {
15 switch (identifier) {
16 case content::BrowserThread::UI:
17 return WebThread::UI;
18 case content::BrowserThread::DB:
19 return WebThread::DB;
20 case content::BrowserThread::FILE:
21 return WebThread::FILE;
22 case content::BrowserThread::FILE_USER_BLOCKING:
23 return WebThread::FILE_USER_BLOCKING;
24 case content::BrowserThread::CACHE:
25 return WebThread::CACHE;
26 case content::BrowserThread::IO:
27 return WebThread::IO;
28 default:
29 NOTREACHED() << "Unknown content::BrowserThread::ID: " << identifier;
30 return WebThread::UI;
34 } // namespace
36 content::BrowserThread::ID BrowserThreadIDFromWebThreadID(
37 WebThread::ID identifier) {
38 switch (identifier) {
39 case WebThread::UI:
40 return content::BrowserThread::UI;
41 case WebThread::DB:
42 return content::BrowserThread::DB;
43 case WebThread::FILE:
44 return content::BrowserThread::FILE;
45 case WebThread::FILE_USER_BLOCKING:
46 return content::BrowserThread::FILE_USER_BLOCKING;
47 case WebThread::CACHE:
48 return content::BrowserThread::CACHE;
49 case WebThread::IO:
50 return content::BrowserThread::IO;
51 default:
52 NOTREACHED() << "Unknown web::WebThread::ID: " << identifier;
53 return content::BrowserThread::UI;
57 #pragma mark - web_thread.h implementation
59 // static
60 bool WebThread::PostTask(ID identifier,
61 const tracked_objects::Location& from_here,
62 const base::Closure& task) {
63 return content::BrowserThread::PostTask(
64 BrowserThreadIDFromWebThreadID(identifier), from_here, task);
67 // static
68 bool WebThread::PostDelayedTask(ID identifier,
69 const tracked_objects::Location& from_here,
70 const base::Closure& task,
71 base::TimeDelta delay) {
72 return content::BrowserThread::PostDelayedTask(
73 BrowserThreadIDFromWebThreadID(identifier), from_here, task, delay);
76 // static
77 bool WebThread::PostNonNestableTask(ID identifier,
78 const tracked_objects::Location& from_here,
79 const base::Closure& task) {
80 return content::BrowserThread::PostNonNestableTask(
81 BrowserThreadIDFromWebThreadID(identifier), from_here, task);
84 // static
85 bool WebThread::PostNonNestableDelayedTask(
86 ID identifier,
87 const tracked_objects::Location& from_here,
88 const base::Closure& task,
89 base::TimeDelta delay) {
90 return content::BrowserThread::PostNonNestableDelayedTask(
91 BrowserThreadIDFromWebThreadID(identifier), from_here, task, delay);
94 // static
95 bool WebThread::PostTaskAndReply(ID identifier,
96 const tracked_objects::Location& from_here,
97 const base::Closure& task,
98 const base::Closure& reply) {
99 return content::BrowserThread::PostTaskAndReply(
100 BrowserThreadIDFromWebThreadID(identifier), from_here, task, reply);
103 // static
104 bool WebThread::PostBlockingPoolTask(const tracked_objects::Location& from_here,
105 const base::Closure& task) {
106 return content::BrowserThread::PostBlockingPoolTask(from_here, task);
109 // static
110 bool WebThread::PostBlockingPoolTaskAndReply(
111 const tracked_objects::Location& from_here,
112 const base::Closure& task,
113 const base::Closure& reply) {
114 return content::BrowserThread::PostBlockingPoolTaskAndReply(from_here, task,
115 reply);
118 // static
119 bool WebThread::PostBlockingPoolSequencedTask(
120 const std::string& sequence_token_name,
121 const tracked_objects::Location& from_here,
122 const base::Closure& task) {
123 return content::BrowserThread::PostBlockingPoolSequencedTask(
124 sequence_token_name, from_here, task);
127 // static
128 base::SequencedWorkerPool* WebThread::GetBlockingPool() {
129 return content::BrowserThread::GetBlockingPool();
132 // static
133 base::MessageLoop* WebThread::UnsafeGetMessageLoopForThread(ID identifier) {
134 return content::BrowserThread::UnsafeGetMessageLoopForThread(
135 BrowserThreadIDFromWebThreadID(identifier));
138 // static
139 bool WebThread::IsThreadInitialized(ID identifier) {
140 return content::BrowserThread::IsThreadInitialized(
141 BrowserThreadIDFromWebThreadID(identifier));
144 // static
145 bool WebThread::CurrentlyOn(ID identifier) {
146 return content::BrowserThread::CurrentlyOn(
147 BrowserThreadIDFromWebThreadID(identifier));
150 // static
151 bool WebThread::IsMessageLoopValid(ID identifier) {
152 return content::BrowserThread::IsMessageLoopValid(
153 BrowserThreadIDFromWebThreadID(identifier));
156 // static
157 bool WebThread::GetCurrentThreadIdentifier(ID* identifier) {
158 content::BrowserThread::ID content_identifier;
159 bool result =
160 content::BrowserThread::GetCurrentThreadIdentifier(&content_identifier);
161 if (result)
162 *identifier = WebThreadIDFromBrowserThreadID(content_identifier);
163 return result;
166 // static
167 scoped_refptr<base::SingleThreadTaskRunner> WebThread::GetTaskRunnerForThread(
168 ID identifier) {
169 return content::BrowserThread::GetMessageLoopProxyForThread(
170 BrowserThreadIDFromWebThreadID(identifier));
173 // static
174 std::string WebThread::GetDCheckCurrentlyOnErrorMessage(ID expected) {
175 return content::BrowserThread::GetDCheckCurrentlyOnErrorMessage(
176 BrowserThreadIDFromWebThreadID(expected));
179 } // namespace web