1 // Copyright (c) 2013 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 #ifndef REMOTING_HOST_WIN_CHROMOTING_MODULE_H_
6 #define REMOTING_HOST_WIN_CHROMOTING_MODULE_H_
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/win/scoped_com_initializer.h"
16 // chromoting_lib.h contains MIDL-generated declarations.
17 #include "remoting/host/chromoting_lib.h"
21 class ScopedCOMInitializer
;
27 class AutoThreadTaskRunner
;
29 // A custom version of |CAtlModuleT<>| that registers only those classes which
30 // registration entries are passed to the constructor. |ChromotingModule| runs
31 // |MessageLoop| allowing Chromium code to post tasks to it. Unlike
32 // |CAtlExeModuleT<>|, |ChromotingModule| shuts itself down immediately once
33 // the last COM object is released.
34 class ChromotingModule
: public ATL::CAtlModuleT
<ChromotingModule
> {
36 // Initializes the module. |classes| and |classes_end| must outlive |this|.
37 ChromotingModule(ATL::_ATL_OBJMAP_ENTRY
* classes
,
38 ATL::_ATL_OBJMAP_ENTRY
* classes_end
);
39 virtual ~ChromotingModule();
41 // Returns the task runner used by the module. Returns NULL if the task runner
42 // hasn't been registered yet or if the server is shutting down.
43 static scoped_refptr
<AutoThreadTaskRunner
> task_runner();
45 // Registers COM classes and runs the main message loop until there are
46 // components using it.
49 // ATL::CAtlModuleT<> overrides
50 virtual LONG
Unlock() OVERRIDE
;
52 DECLARE_LIBID(LIBID_ChromotingLib
)
55 // Registers/unregisters class objects from |classes_| - |classes_end_|.
56 HRESULT
RegisterClassObjects(DWORD class_context
, DWORD flags
);
57 HRESULT
RevokeClassObjects();
59 // Used to initialize COM library.
60 base::win::ScopedCOMInitializer com_initializer_
;
62 // Point to the vector of classes registered by this module.
63 ATL::_ATL_OBJMAP_ENTRY
* classes_
;
64 ATL::_ATL_OBJMAP_ENTRY
* classes_end_
;
66 DISALLOW_COPY_AND_ASSIGN(ChromotingModule
);
69 } // namespace remoting
71 #endif // REMOTING_HOST_WIN_CHROMOTING_MODULE_H_