Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / apps / app_shim / app_shim_host_manager_mac.h
blob47d2d9abd58c89dc692e199ce5de421bfa8c2276
1 // Copyright 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 CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
6 #define CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h"
10 #include "content/public/browser/browser_thread.h"
12 namespace apps {
13 class ExtensionAppShimHandler;
16 namespace base {
17 class FilePath;
20 namespace test {
21 class AppShimHostManagerTestApi;
24 // The AppShimHostManager receives connections from app shims on a UNIX
25 // socket (|acceptor_|) and creates a helper object to manage the connection.
26 class AppShimHostManager : public apps::UnixDomainSocketAcceptor::Delegate,
27 public base::RefCountedThreadSafe<
28 AppShimHostManager,
29 content::BrowserThread::DeleteOnUIThread> {
30 public:
31 AppShimHostManager();
33 // Init passes this AppShimHostManager to PostTask which requires it to have
34 // a non-zero refcount. Therefore, Init cannot be called in the constructor
35 // since the refcount is zero at that point.
36 void Init();
38 apps::ExtensionAppShimHandler* extension_app_shim_handler() {
39 return extension_app_shim_handler_.get();
42 private:
43 friend class base::RefCountedThreadSafe<AppShimHostManager>;
44 friend struct content::BrowserThread::DeleteOnThread<
45 content::BrowserThread::UI>;
46 friend class base::DeleteHelper<AppShimHostManager>;
47 friend class test::AppShimHostManagerTestApi;
48 virtual ~AppShimHostManager();
50 // UnixDomainSocketAcceptor::Delegate implementation.
51 void OnClientConnected(const IPC::ChannelHandle& handle) override;
52 void OnListenError() override;
54 // The |acceptor_| must be created on a thread which allows blocking I/O, so
55 // part of the initialization of this class must be carried out on the file
56 // thread.
57 void InitOnFileThread();
59 // Called on the IO thread to begin listening for connections from app shims.
60 void ListenOnIOThread();
62 base::FilePath directory_in_tmp_;
64 scoped_ptr<apps::UnixDomainSocketAcceptor> acceptor_;
66 scoped_ptr<apps::ExtensionAppShimHandler> extension_app_shim_handler_;
68 DISALLOW_COPY_AND_ASSIGN(AppShimHostManager);
71 #endif // CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_