ozone: Fix typo in platform_object.h
[chromium-blink-merge.git] / apps / app_shim / app_shim_host_manager_mac.h
blob037c4f24b1cd9f052a7dad6b7b04a00bd2f3d48c
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 APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
6 #define APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_
8 #include "apps/app_shim/extension_app_shim_handler_mac.h"
9 #include "apps/app_shim/unix_domain_socket_acceptor.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/browser_thread.h"
13 namespace base {
14 class FilePath;
17 namespace test {
18 class AppShimHostManagerTestApi;
21 // The AppShimHostManager receives connections from app shims on a UNIX
22 // socket (|acceptor_|) and creates a helper object to manage the connection.
23 class AppShimHostManager : public apps::UnixDomainSocketAcceptor::Delegate,
24 public base::RefCountedThreadSafe<
25 AppShimHostManager,
26 content::BrowserThread::DeleteOnUIThread> {
27 public:
28 AppShimHostManager();
30 // Init passes this AppShimHostManager to PostTask which requires it to have
31 // a non-zero refcount. Therefore, Init cannot be called in the constructor
32 // since the refcount is zero at that point.
33 void Init();
35 apps::ExtensionAppShimHandler* extension_app_shim_handler() {
36 return &extension_app_shim_handler_;
39 private:
40 friend class base::RefCountedThreadSafe<AppShimHostManager>;
41 friend struct content::BrowserThread::DeleteOnThread<
42 content::BrowserThread::UI>;
43 friend class base::DeleteHelper<AppShimHostManager>;
44 friend class test::AppShimHostManagerTestApi;
45 virtual ~AppShimHostManager();
47 // UnixDomainSocketAcceptor::Delegate implementation.
48 virtual void OnClientConnected(const IPC::ChannelHandle& handle) OVERRIDE;
49 virtual void OnListenError() OVERRIDE;
51 // The |acceptor_| must be created on a thread which allows blocking I/O, so
52 // part of the initialization of this class must be carried out on the file
53 // thread.
54 void InitOnFileThread();
56 // Called on the IO thread to begin listening for connections from app shims.
57 void ListenOnIOThread();
59 // The AppShimHostManager is only initialized if the Chrome process
60 // successfully took the singleton lock. This prevents subsequent processes
61 // from deleting existing app shim socket files.
62 bool did_init_;
64 base::FilePath directory_in_tmp_;
66 scoped_ptr<apps::UnixDomainSocketAcceptor> acceptor_;
68 apps::ExtensionAppShimHandler extension_app_shim_handler_;
70 DISALLOW_COPY_AND_ASSIGN(AppShimHostManager);
73 #endif // APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_