Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: content/browser/mojo/mojo_application_host.h

Issue 1883323002: Reland of Use a token to initialise ChannelMojo and MojoApplication everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/browser/mojo/mojo_application_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_
6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ 6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/process/process_handle.h"
13 #include "build/build_config.h" 12 #include "build/build_config.h"
14 #include "content/common/application_setup.mojom.h" 13 #include "content/common/application_setup.mojom.h"
15 #include "content/common/mojo/channel_init.h"
16 #include "content/common/mojo/service_registry_impl.h" 14 #include "content/common/mojo/service_registry_impl.h"
17 #include "mojo/edk/embedder/scoped_platform_handle.h"
18 #include "mojo/public/cpp/system/message_pipe.h"
19 15
20 #if defined(OS_ANDROID) 16 #if defined(OS_ANDROID)
21 #include "content/public/browser/android/service_registry_android.h" 17 #include "content/public/browser/android/service_registry_android.h"
22 #endif 18 #endif
23 19
24 namespace IPC { 20 namespace IPC {
25 class Sender; 21 class Sender;
26 } 22 }
27 23
28 namespace content { 24 namespace content {
29 25
30 // MojoApplicationHost represents the code needed on the browser side to setup 26 // MojoApplicationHost represents the code needed on the browser side to setup
31 // a child process as a Mojo application via Chrome IPC. The child process 27 // a child process as a Mojo application. The child process should use the token
32 // should use MojoApplication to handle messages generated by an instance of 28 // from GetToken() to initialize its MojoApplication. MojoApplicationHost makes
33 // MojoApplicationHost. MojoApplicationHost makes the ServiceRegistry interface 29 // the ServiceRegistry interface available so that child-provided services can
34 // available so that child-provided services can be invoked. 30 // be invoked.
35 class CONTENT_EXPORT MojoApplicationHost { 31 class CONTENT_EXPORT MojoApplicationHost {
36 public: 32 public:
37 MojoApplicationHost(); 33 MojoApplicationHost();
38 ~MojoApplicationHost(); 34 ~MojoApplicationHost();
39 35
40 // Two-phase initialization: 36 // Returns a token to pass to the child process to initialize its
41 // 1- Init makes service_registry() available synchronously. 37 // MojoApplication.
42 // 2- Activate establishes the actual connection to the peer process. 38 const std::string& GetToken() { return token_; }
43 bool Init();
44 void Activate(IPC::Sender* sender, base::ProcessHandle process_handle);
45
46 // Use a shared token to initialize the application. Returns a token to pass
47 // to the child process.
48 std::string InitWithToken();
49 39
50 ServiceRegistry* service_registry() { return &service_registry_; } 40 ServiceRegistry* service_registry() { return &service_registry_; }
51 41
52 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
53 ServiceRegistryAndroid* service_registry_android() { 43 ServiceRegistryAndroid* service_registry_android() {
54 return service_registry_android_.get(); 44 return service_registry_android_.get();
55 } 45 }
56 #endif 46 #endif
57 47
58 void OverrideIOTaskRunnerForTest(
59 scoped_refptr<base::TaskRunner> io_task_runner);
60
61 private: 48 private:
62 ChannelInit channel_init_; 49 const std::string token_;
63 mojo::edk::ScopedPlatformHandle client_handle_;
64
65 bool did_activate_;
66 50
67 std::unique_ptr<mojom::ApplicationSetup> application_setup_; 51 std::unique_ptr<mojom::ApplicationSetup> application_setup_;
68 ServiceRegistryImpl service_registry_; 52 ServiceRegistryImpl service_registry_;
69 53
70 scoped_refptr<base::TaskRunner> io_task_runner_override_;
71
72 #if defined(OS_ANDROID) 54 #if defined(OS_ANDROID)
73 std::unique_ptr<ServiceRegistryAndroid> service_registry_android_; 55 std::unique_ptr<ServiceRegistryAndroid> service_registry_android_;
74 #endif 56 #endif
75 57
76 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost); 58 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost);
77 }; 59 };
78 60
79 } // namespace content 61 } // namespace content
80 62
81 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ 63 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/browser/mojo/mojo_application_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698