| 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 CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // | 32 // |
| 33 // This class must only be created, called, and deleted on the IO thread. | 33 // This class must only be created, called, and deleted on the IO thread. |
| 34 // Public methods typically accept callbacks which will be invoked on the UI | 34 // Public methods typically accept callbacks which will be invoked on the UI |
| 35 // thread. | 35 // thread. |
| 36 class NativeMessageProcessHost : | 36 class NativeMessageProcessHost : |
| 37 #if defined(OS_POSIX) | 37 #if defined(OS_POSIX) |
| 38 public base::MessageLoopForIO::Watcher, | 38 public base::MessageLoopForIO::Watcher, |
| 39 #endif // !defined(OS_POSIX) | 39 #endif // !defined(OS_POSIX) |
| 40 public NativeMessageHost { | 40 public NativeMessageHost { |
| 41 public: | 41 public: |
| 42 virtual ~NativeMessageProcessHost(); | 42 ~NativeMessageProcessHost() override; |
| 43 | 43 |
| 44 // Create using specified |launcher|. Used in tests. | 44 // Create using specified |launcher|. Used in tests. |
| 45 static scoped_ptr<NativeMessageHost> CreateWithLauncher( | 45 static scoped_ptr<NativeMessageHost> CreateWithLauncher( |
| 46 const std::string& source_extension_id, | 46 const std::string& source_extension_id, |
| 47 const std::string& native_host_name, | 47 const std::string& native_host_name, |
| 48 scoped_ptr<NativeProcessLauncher> launcher); | 48 scoped_ptr<NativeProcessLauncher> launcher); |
| 49 | 49 |
| 50 // extensions::NativeMessageHost implementation. | 50 // extensions::NativeMessageHost implementation. |
| 51 virtual void OnMessage(const std::string& message) override; | 51 void OnMessage(const std::string& message) override; |
| 52 virtual void Start(Client* client) override; | 52 void Start(Client* client) override; |
| 53 virtual scoped_refptr<base::SingleThreadTaskRunner> task_runner() | 53 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; |
| 54 const override; | |
| 55 | 54 |
| 56 #if defined(OS_POSIX) | 55 #if defined(OS_POSIX) |
| 57 // MessageLoopForIO::Watcher interface | 56 // MessageLoopForIO::Watcher interface |
| 58 virtual void OnFileCanReadWithoutBlocking(int fd) override; | 57 void OnFileCanReadWithoutBlocking(int fd) override; |
| 59 virtual void OnFileCanWriteWithoutBlocking(int fd) override; | 58 void OnFileCanWriteWithoutBlocking(int fd) override; |
| 60 #endif // !defined(OS_POSIX) | 59 #endif // !defined(OS_POSIX) |
| 61 | 60 |
| 62 // Try and read a single message from |read_file_|. This should only be called | 61 // Try and read a single message from |read_file_|. This should only be called |
| 63 // in unittests when you know there is data in the file. | 62 // in unittests when you know there is data in the file. |
| 64 void ReadNowForTesting(); | 63 void ReadNowForTesting(); |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 NativeMessageProcessHost(const std::string& source_extension_id, | 66 NativeMessageProcessHost(const std::string& source_extension_id, |
| 68 const std::string& native_host_name, | 67 const std::string& native_host_name, |
| 69 scoped_ptr<NativeProcessLauncher> launcher); | 68 scoped_ptr<NativeProcessLauncher> launcher); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool write_pending_; | 140 bool write_pending_; |
| 142 | 141 |
| 143 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 142 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 144 | 143 |
| 145 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); | 144 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 } // namespace extensions | 147 } // namespace extensions |
| 149 | 148 |
| 150 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ | 149 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ |
| OLD | NEW |