Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / remoting / host / win / chromoting_module.h
blobb20184a8d5bd31149480e28813ce2fa446eeec21
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_
8 #include <atlbase.h>
9 #include <atlcom.h>
10 #include <atlctl.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"
19 namespace base {
20 namespace win {
21 class ScopedCOMInitializer;
22 } // namespace win
23 } // namespace base
25 namespace remoting {
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> {
35 public:
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 nullptr if the task
42 // runner 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.
47 bool Run();
49 // ATL::CAtlModuleT<> overrides
50 virtual LONG Unlock() override;
52 DECLARE_LIBID(LIBID_ChromotingLib)
54 private:
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_