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

Side by Side Diff: base/threading/com_thread.h

Issue 11048029: Allow Thread to initialize COM for Windows consumers who need it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // ComThread is a Thread which, on Windows, initializes COM on the spawned
6 // thread when it's created and shuts down COM just before the spawned thread is
7 // destroyed. On non-Windows, ComThread is identical to Thread. This allows
8 // consumers to use ComThread in cross-platform code without having to do any
9 // conditional #includes or typedefs of their own.
10
11 #ifndef BASE_THREADING_COM_THREAD_H_
12 #define BASE_THREADING_COM_THREAD_H_
13
14 #include "base/threading/thread.h"
15
16 #if defined(OS_WIN)
17 #include "base/memory/scoped_ptr.h"
18 #include "base/win/scoped_com_initializer.h"
19 #endif
20
21 namespace base {
22
23 class BASE_EXPORT ComThread : public Thread {
24 public:
25 #if defined(OS_WIN)
26 ComThread(const char* name, bool use_mta);
27 virtual ~ComThread();
28
29 bool Start();
30
31 protected:
32 virtual void Init() OVERRIDE; // Creates com_initializer_.
33 virtual void CleanUp() OVERRIDE; // Destroys com_initializer_.
34
35 private:
36 bool use_mta_;
37 scoped_ptr<win::ScopedCOMInitializer> com_initializer_;
38 #else
39 ComThread(const char* name, bool use_mta) : Thread(name) {}
40 virtual ~ComThread() {}
41 #endif
42
43 DISALLOW_COPY_AND_ASSIGN(ComThread);
44 };
45
46 } // namespace base
47
48 #endif // BASE_THREADING_COM_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698