OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ |
6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ | 6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
11 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" | 11 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" |
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" |
| 14 |
13 namespace mojo { | 15 namespace mojo { |
14 | 16 |
15 class ApplicationImpl; | 17 class ApplicationImpl; |
16 class ViewManagerDelegate; | 18 class ViewManagerDelegate; |
17 | 19 |
18 // ViewManagerInit is used to establish the initial connection to the | 20 // ViewManagerInit is used to establish the initial connection to the |
19 // ViewManager. Use it when you know the ViewManager is not running and you're | 21 // ViewManager. Use it when you know the ViewManager is not running and you're |
20 // app is going to be the first one to contact it. | 22 // app is going to be the first one to contact it. |
21 class ViewManagerInit { | 23 class ViewManagerInit : public mojo::ErrorHandler { |
22 public: | 24 public: |
23 // |root_client| is optional. | 25 // |root_client| is optional. |
24 ViewManagerInit(ApplicationImpl* app, | 26 ViewManagerInit(ApplicationImpl* app, |
25 ViewManagerDelegate* delegate, | 27 ViewManagerDelegate* delegate, |
26 ViewManagerRootClient* root_client); | 28 ViewManagerRootClient* root_client); |
27 ~ViewManagerInit(); | 29 ~ViewManagerInit() override; |
28 | 30 |
29 // Returns the ViewManagerRoot. This is only valid if |root_client| was | 31 // Returns the ViewManagerRoot. This is only valid if |root_client| was |
30 // supplied to the constructor. | 32 // supplied to the constructor. |
31 ViewManagerRoot* view_manager_root() { return view_manager_root_.get(); } | 33 ViewManagerRoot* view_manager_root() { return view_manager_root_.get(); } |
32 | 34 |
33 private: | 35 private: |
34 class ClientFactory; | 36 class ClientFactory; |
35 | 37 |
36 void OnCreate(InterfaceRequest<ViewManagerClient> request); | 38 void OnCreate(InterfaceRequest<ViewManagerClient> request); |
37 | 39 |
| 40 // ErrorHandler: |
| 41 void OnConnectionError() override; |
| 42 |
38 ApplicationImpl* app_; | 43 ApplicationImpl* app_; |
39 ViewManagerDelegate* delegate_; | 44 ViewManagerDelegate* delegate_; |
40 scoped_ptr<ClientFactory> client_factory_; | 45 scoped_ptr<ClientFactory> client_factory_; |
41 ViewManagerServicePtr service_; | 46 ViewManagerServicePtr service_; |
42 ViewManagerRootPtr view_manager_root_; | 47 ViewManagerRootPtr view_manager_root_; |
43 scoped_ptr<Binding<ViewManagerRootClient>> root_client_binding_; | 48 scoped_ptr<Binding<ViewManagerRootClient>> root_client_binding_; |
44 | 49 |
45 DISALLOW_COPY_AND_ASSIGN(ViewManagerInit); | 50 DISALLOW_COPY_AND_ASSIGN(ViewManagerInit); |
46 }; | 51 }; |
47 | 52 |
48 } // namespace mojo | 53 } // namespace mojo |
49 | 54 |
50 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ | 55 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_INIT_H_ |
OLD | NEW |