| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHILD_CONNECTION_H_ | 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ |
| 6 #define CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ | 6 #define CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_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/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "services/shell/public/cpp/identity.h" |
| 16 #include "services/shell/public/cpp/interface_provider.h" | 17 #include "services/shell/public/cpp/interface_provider.h" |
| 17 #include "services/shell/public/cpp/interface_registry.h" | 18 #include "services/shell/public/cpp/interface_registry.h" |
| 18 #include "services/shell/public/interfaces/connector.mojom.h" | 19 #include "services/shell/public/interfaces/connector.mojom.h" |
| 19 | 20 |
| 20 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 21 #include "content/public/browser/android/interface_registry_android.h" | 22 #include "content/public/browser/android/interface_registry_android.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace shell { | 25 namespace shell { |
| 25 class Connection; | 26 class Connection; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 ~MojoChildConnection(); | 46 ~MojoChildConnection(); |
| 46 | 47 |
| 47 shell::InterfaceRegistry* GetInterfaceRegistry() { | 48 shell::InterfaceRegistry* GetInterfaceRegistry() { |
| 48 return &interface_registry_; | 49 return &interface_registry_; |
| 49 } | 50 } |
| 50 | 51 |
| 51 shell::InterfaceProvider* GetRemoteInterfaces() { | 52 shell::InterfaceProvider* GetRemoteInterfaces() { |
| 52 return &remote_interfaces_; | 53 return &remote_interfaces_; |
| 53 } | 54 } |
| 54 | 55 |
| 56 const shell::Identity& child_identity() const { |
| 57 return child_identity_; |
| 58 } |
| 59 |
| 55 // A token which must be passed to the child process via | 60 // A token which must be passed to the child process via |
| 56 // |switches::kPrimordialPipeToken| in order for the child to initialize its | 61 // |switches::kPrimordialPipeToken| in order for the child to initialize its |
| 57 // end of the shell connection pipe. | 62 // end of the shell connection pipe. |
| 58 std::string service_token() const { return service_token_; } | 63 std::string service_token() const { return service_token_; } |
| 59 | 64 |
| 60 // Sets the child connection's process handle. This should be called as soon | 65 // Sets the child connection's process handle. This should be called as soon |
| 61 // as the process has been launched, and the connection will not be fully | 66 // as the process has been launched, and the connection will not be fully |
| 62 // functional until this is called. | 67 // functional until this is called. |
| 63 void SetProcessHandle(base::ProcessHandle handle); | 68 void SetProcessHandle(base::ProcessHandle handle); |
| 64 | 69 |
| 65 #if defined(OS_ANDROID) | |
| 66 InterfaceRegistryAndroid* interface_registry_android() { | |
| 67 return interface_registry_android_.get(); | |
| 68 } | |
| 69 #endif | |
| 70 | |
| 71 private: | 70 private: |
| 72 class IOThreadContext; | 71 class IOThreadContext; |
| 73 | 72 |
| 74 void GetInterface(const mojo::String& interface_name, | 73 void GetInterface(const mojo::String& interface_name, |
| 75 mojo::ScopedMessagePipeHandle request_handle); | 74 mojo::ScopedMessagePipeHandle request_handle); |
| 76 | 75 |
| 77 scoped_refptr<IOThreadContext> context_; | 76 scoped_refptr<IOThreadContext> context_; |
| 78 | 77 shell::Identity child_identity_; |
| 79 const std::string service_token_; | 78 const std::string service_token_; |
| 80 | 79 |
| 81 shell::InterfaceRegistry interface_registry_; | 80 shell::InterfaceRegistry interface_registry_; |
| 82 shell::InterfaceProvider remote_interfaces_; | 81 shell::InterfaceProvider remote_interfaces_; |
| 83 | 82 |
| 84 #if defined(OS_ANDROID) | 83 #if defined(OS_ANDROID) |
| 85 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; | 84 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; |
| 86 #endif | 85 #endif |
| 87 | 86 |
| 88 base::WeakPtrFactory<MojoChildConnection> weak_factory_; | 87 base::WeakPtrFactory<MojoChildConnection> weak_factory_; |
| 89 | 88 |
| 90 DISALLOW_COPY_AND_ASSIGN(MojoChildConnection); | 89 DISALLOW_COPY_AND_ASSIGN(MojoChildConnection); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace content | 92 } // namespace content |
| 94 | 93 |
| 95 #endif // CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ | 94 #endif // CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ |
| OLD | NEW |