| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHILD_CHILD_THREAD_IMPL_H_ | 5 #ifndef CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // process. | 196 // process. |
| 197 static void ShutdownThread(); | 197 static void ShutdownThread(); |
| 198 #endif | 198 #endif |
| 199 | 199 |
| 200 protected: | 200 protected: |
| 201 friend class ChildProcess; | 201 friend class ChildProcess; |
| 202 | 202 |
| 203 // Called when the process refcount is 0. | 203 // Called when the process refcount is 0. |
| 204 void OnProcessFinalRelease(); | 204 void OnProcessFinalRelease(); |
| 205 | 205 |
| 206 // Implemented by subclasses to attach ConnectionFilters to the thread's | 206 // Called by subclasses to manually start the MojoShellConnection. Must only |
| 207 // shell connection. | 207 // be called if ChildThreadImpl::Options::auto_start_mojo_shell_connection |
| 208 virtual void AddConnectionFilters(MojoShellConnection* connection); | 208 // was set to |false| on ChildThreadImpl construction. |
| 209 void StartMojoShellConnection(); |
| 209 | 210 |
| 210 virtual bool OnControlMessageReceived(const IPC::Message& msg); | 211 virtual bool OnControlMessageReceived(const IPC::Message& msg); |
| 211 virtual void OnProcessBackgrounded(bool backgrounded); | 212 virtual void OnProcessBackgrounded(bool backgrounded); |
| 212 virtual void OnProcessPurgeAndSuspend(); | 213 virtual void OnProcessPurgeAndSuspend(); |
| 213 | 214 |
| 214 // IPC::Listener implementation: | 215 // IPC::Listener implementation: |
| 215 bool OnMessageReceived(const IPC::Message& msg) override; | 216 bool OnMessageReceived(const IPC::Message& msg) override; |
| 216 void OnChannelConnected(int32_t peer_pid) override; | 217 void OnChannelConnected(int32_t peer_pid) override; |
| 217 void OnChannelError() override; | 218 void OnChannelError() override; |
| 218 | 219 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 }; | 317 }; |
| 317 | 318 |
| 318 struct ChildThreadImpl::Options { | 319 struct ChildThreadImpl::Options { |
| 319 Options(const Options& other); | 320 Options(const Options& other); |
| 320 ~Options(); | 321 ~Options(); |
| 321 | 322 |
| 322 class Builder; | 323 class Builder; |
| 323 | 324 |
| 324 std::string channel_name; | 325 std::string channel_name; |
| 325 bool use_mojo_channel; | 326 bool use_mojo_channel; |
| 327 bool auto_start_mojo_shell_connection; |
| 326 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner; | 328 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner; |
| 327 std::vector<IPC::MessageFilter*> startup_filters; | 329 std::vector<IPC::MessageFilter*> startup_filters; |
| 328 std::string in_process_ipc_token; | 330 std::string in_process_ipc_token; |
| 329 std::string in_process_application_token; | 331 std::string in_process_application_token; |
| 330 | 332 |
| 331 private: | 333 private: |
| 332 Options(); | 334 Options(); |
| 333 }; | 335 }; |
| 334 | 336 |
| 335 class ChildThreadImpl::Options::Builder { | 337 class ChildThreadImpl::Options::Builder { |
| 336 public: | 338 public: |
| 337 Builder(); | 339 Builder(); |
| 338 | 340 |
| 339 Builder& InBrowserProcess(const InProcessChildThreadParams& params); | 341 Builder& InBrowserProcess(const InProcessChildThreadParams& params); |
| 340 Builder& UseMojoChannel(bool use_mojo_channel); | 342 Builder& UseMojoChannel(bool use_mojo_channel); |
| 343 Builder& AutoStartMojoShellConnection(bool auto_start); |
| 341 Builder& WithChannelName(const std::string& channel_name); | 344 Builder& WithChannelName(const std::string& channel_name); |
| 342 Builder& AddStartupFilter(IPC::MessageFilter* filter); | 345 Builder& AddStartupFilter(IPC::MessageFilter* filter); |
| 343 | 346 |
| 344 Options Build(); | 347 Options Build(); |
| 345 | 348 |
| 346 private: | 349 private: |
| 347 struct Options options_; | 350 struct Options options_; |
| 348 | 351 |
| 349 DISALLOW_COPY_AND_ASSIGN(Builder); | 352 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 350 }; | 353 }; |
| 351 | 354 |
| 352 } // namespace content | 355 } // namespace content |
| 353 | 356 |
| 354 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 357 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| OLD | NEW |