OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // with BrowserThread. | 179 // with BrowserThread. |
180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
181 public: | 181 public: |
182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
183 : id_(identifier) { | 183 : id_(identifier) { |
184 } | 184 } |
185 | 185 |
186 // MessageLoopProxy implementation. | 186 // MessageLoopProxy implementation. |
187 virtual bool PostDelayedTask( | 187 virtual bool PostDelayedTask( |
188 const tracked_objects::Location& from_here, | 188 const tracked_objects::Location& from_here, |
189 const base::Closure& task, int64 delay_ms) OVERRIDE { | |
190 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | |
191 } | |
192 virtual bool PostDelayedTask( | |
193 const tracked_objects::Location& from_here, | |
194 const base::Closure& task, base::TimeDelta delay) OVERRIDE { | 189 const base::Closure& task, base::TimeDelta delay) OVERRIDE { |
195 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); | 190 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); |
196 } | 191 } |
197 | 192 |
198 virtual bool PostNonNestableDelayedTask( | 193 virtual bool PostNonNestableDelayedTask( |
199 const tracked_objects::Location& from_here, | 194 const tracked_objects::Location& from_here, |
200 const base::Closure& task, | 195 const base::Closure& task, |
201 int64 delay_ms) OVERRIDE { | |
202 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | |
203 delay_ms); | |
204 } | |
205 virtual bool PostNonNestableDelayedTask( | |
206 const tracked_objects::Location& from_here, | |
207 const base::Closure& task, | |
208 base::TimeDelta delay) OVERRIDE { | 196 base::TimeDelta delay) OVERRIDE { |
209 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 197 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
210 delay); | 198 delay); |
211 } | 199 } |
212 | 200 |
213 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { | 201 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
214 return BrowserThread::CurrentlyOn(id_); | 202 return BrowserThread::CurrentlyOn(id_); |
215 } | 203 } |
216 | 204 |
217 private: | 205 private: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 const tracked_objects::Location& from_here, | 271 const tracked_objects::Location& from_here, |
284 const base::Closure& task) { | 272 const base::Closure& task) { |
285 return BrowserThreadImpl::PostTaskHelper( | 273 return BrowserThreadImpl::PostTaskHelper( |
286 identifier, from_here, task, base::TimeDelta(), true); | 274 identifier, from_here, task, base::TimeDelta(), true); |
287 } | 275 } |
288 | 276 |
289 // static | 277 // static |
290 bool BrowserThread::PostDelayedTask(ID identifier, | 278 bool BrowserThread::PostDelayedTask(ID identifier, |
291 const tracked_objects::Location& from_here, | 279 const tracked_objects::Location& from_here, |
292 const base::Closure& task, | 280 const base::Closure& task, |
293 int64 delay_ms) { | |
294 return BrowserThreadImpl::PostTaskHelper( | |
295 identifier, | |
296 from_here, | |
297 task, | |
298 base::TimeDelta::FromMilliseconds(delay_ms), | |
299 true); | |
300 } | |
301 | |
302 // static | |
303 bool BrowserThread::PostDelayedTask(ID identifier, | |
304 const tracked_objects::Location& from_here, | |
305 const base::Closure& task, | |
306 base::TimeDelta delay) { | 281 base::TimeDelta delay) { |
307 return BrowserThreadImpl::PostTaskHelper( | 282 return BrowserThreadImpl::PostTaskHelper( |
308 identifier, from_here, task, delay, true); | 283 identifier, from_here, task, delay, true); |
309 } | 284 } |
310 | 285 |
311 // static | 286 // static |
312 bool BrowserThread::PostNonNestableTask( | 287 bool BrowserThread::PostNonNestableTask( |
313 ID identifier, | 288 ID identifier, |
314 const tracked_objects::Location& from_here, | 289 const tracked_objects::Location& from_here, |
315 const base::Closure& task) { | 290 const base::Closure& task) { |
316 return BrowserThreadImpl::PostTaskHelper( | 291 return BrowserThreadImpl::PostTaskHelper( |
317 identifier, from_here, task, base::TimeDelta(), false); | 292 identifier, from_here, task, base::TimeDelta(), false); |
318 } | 293 } |
319 | 294 |
320 // static | 295 // static |
321 bool BrowserThread::PostNonNestableDelayedTask( | 296 bool BrowserThread::PostNonNestableDelayedTask( |
322 ID identifier, | 297 ID identifier, |
323 const tracked_objects::Location& from_here, | 298 const tracked_objects::Location& from_here, |
324 const base::Closure& task, | 299 const base::Closure& task, |
325 int64 delay_ms) { | |
326 return BrowserThreadImpl::PostTaskHelper( | |
327 identifier, | |
328 from_here, | |
329 task, | |
330 base::TimeDelta::FromMilliseconds(delay_ms), | |
331 false); | |
332 } | |
333 | |
334 // static | |
335 bool BrowserThread::PostNonNestableDelayedTask( | |
336 ID identifier, | |
337 const tracked_objects::Location& from_here, | |
338 const base::Closure& task, | |
339 base::TimeDelta delay) { | 300 base::TimeDelta delay) { |
340 return BrowserThreadImpl::PostTaskHelper( | 301 return BrowserThreadImpl::PostTaskHelper( |
341 identifier, from_here, task, delay, false); | 302 identifier, from_here, task, delay, false); |
342 } | 303 } |
343 | 304 |
344 // static | 305 // static |
345 bool BrowserThread::PostTaskAndReply( | 306 bool BrowserThread::PostTaskAndReply( |
346 ID identifier, | 307 ID identifier, |
347 const tracked_objects::Location& from_here, | 308 const tracked_objects::Location& from_here, |
348 const base::Closure& task, | 309 const base::Closure& task, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 365 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
405 &globals.thread_delegates[identifier]); | 366 &globals.thread_delegates[identifier]); |
406 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 367 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
407 storage, reinterpret_cast<AtomicWord>(delegate)); | 368 storage, reinterpret_cast<AtomicWord>(delegate)); |
408 | 369 |
409 // This catches registration when previously registered. | 370 // This catches registration when previously registered. |
410 DCHECK(!delegate || !old_pointer); | 371 DCHECK(!delegate || !old_pointer); |
411 } | 372 } |
412 | 373 |
413 } // namespace content | 374 } // namespace content |
OLD | NEW |