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

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 242513006: Support COM in SequencedWorkerPool. This will be used by some code that (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 8 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 | base/win/scoped_com_initializer.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 (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 "base/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 14 matching lines...) Expand all
25 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
26 #include "base/threading/platform_thread.h" 26 #include "base/threading/platform_thread.h"
27 #include "base/threading/simple_thread.h" 27 #include "base/threading/simple_thread.h"
28 #include "base/threading/thread_local.h" 28 #include "base/threading/thread_local.h"
29 #include "base/threading/thread_restrictions.h" 29 #include "base/threading/thread_restrictions.h"
30 #include "base/time/time.h" 30 #include "base/time/time.h"
31 #include "base/tracked_objects.h" 31 #include "base/tracked_objects.h"
32 32
33 #if defined(OS_MACOSX) 33 #if defined(OS_MACOSX)
34 #include "base/mac/scoped_nsautorelease_pool.h" 34 #include "base/mac/scoped_nsautorelease_pool.h"
35 #elif defined(OS_WIN)
36 #include "base/win/scoped_com_initializer.h"
35 #endif 37 #endif
36 38
37 #if !defined(OS_NACL) 39 #if !defined(OS_NACL)
38 #include "base/metrics/histogram.h" 40 #include "base/metrics/histogram.h"
39 #endif 41 #endif
40 42
41 namespace base { 43 namespace base {
42 44
43 namespace { 45 namespace {
44 46
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 prefix + StringPrintf("Worker%d", thread_number).c_str()), 486 prefix + StringPrintf("Worker%d", thread_number).c_str()),
485 worker_pool_(worker_pool), 487 worker_pool_(worker_pool),
486 running_shutdown_behavior_(CONTINUE_ON_SHUTDOWN) { 488 running_shutdown_behavior_(CONTINUE_ON_SHUTDOWN) {
487 Start(); 489 Start();
488 } 490 }
489 491
490 SequencedWorkerPool::Worker::~Worker() { 492 SequencedWorkerPool::Worker::~Worker() {
491 } 493 }
492 494
493 void SequencedWorkerPool::Worker::Run() { 495 void SequencedWorkerPool::Worker::Run() {
496 #if defined(OS_WIN)
497 scoped_ptr<win::ScopedCOMInitializer> com_initializer(
darin (slow to review) 2014/04/19 04:49:07 nit: why heap allocate? why bother with |new| and
Peter Kasting 2014/04/21 20:38:37 Probably because I was copying code from elsewhere
498 new win::ScopedCOMInitializer());
499 #endif
500
494 // Store a pointer to the running sequence in thread local storage for 501 // Store a pointer to the running sequence in thread local storage for
495 // static function access. 502 // static function access.
496 g_lazy_tls_ptr.Get().Set(&running_sequence_); 503 g_lazy_tls_ptr.Get().Set(&running_sequence_);
497 504
498 // Just jump back to the Inner object to run the thread, since it has all the 505 // Just jump back to the Inner object to run the thread, since it has all the
499 // tracking information and queues. It might be more natural to implement 506 // tracking information and queues. It might be more natural to implement
500 // using DelegateSimpleThread and have Inner implement the Delegate to avoid 507 // using DelegateSimpleThread and have Inner implement the Delegate to avoid
501 // having these worker objects at all, but that method lacks the ability to 508 // having these worker objects at all, but that method lacks the ability to
502 // send thread-specific information easily to the thread loop. 509 // send thread-specific information easily to the thread loop.
503 worker_pool_->inner_->ThreadLoop(this); 510 worker_pool_->inner_->ThreadLoop(this);
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1287 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1281 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1288 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1282 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1289 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1283 } 1290 }
1284 1291
1285 bool SequencedWorkerPool::IsShutdownInProgress() { 1292 bool SequencedWorkerPool::IsShutdownInProgress() {
1286 return inner_->IsShutdownInProgress(); 1293 return inner_->IsShutdownInProgress();
1287 } 1294 }
1288 1295
1289 } // namespace base 1296 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/win/scoped_com_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698