| 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 CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ | 5 #ifndef CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ |
| 6 #define CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ | 6 #define CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/sequence_checker.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "chromeos/chromeos_export.h" | 18 #include "chromeos/chromeos_export.h" |
| 19 #include "chromeos/process_proxy/process_proxy.h" | 19 #include "chromeos/process_proxy/process_proxy.h" |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 | 22 |
| 23 // Keeps track of all created ProcessProxies. It is created lazily and should | 23 // Keeps track of all created ProcessProxies. It is created lazily and should |
| 24 // live on a single thread (where all methods must be called). | 24 // live on a single thread (where all methods must be called). |
| 25 class CHROMEOS_EXPORT ProcessProxyRegistry : public base::NonThreadSafe { | 25 class CHROMEOS_EXPORT ProcessProxyRegistry { |
| 26 public: | 26 public: |
| 27 using OutputCallback = base::Callback<void(int terminal_id, | 27 using OutputCallback = base::Callback<void(int terminal_id, |
| 28 const std::string& output_type, | 28 const std::string& output_type, |
| 29 const std::string& output_data)>; | 29 const std::string& output_data)>; |
| 30 | 30 |
| 31 // Info we need about a ProcessProxy instance. | 31 // Info we need about a ProcessProxy instance. |
| 32 struct ProcessProxyInfo { | 32 struct ProcessProxyInfo { |
| 33 scoped_refptr<ProcessProxy> proxy; | 33 scoped_refptr<ProcessProxy> proxy; |
| 34 OutputCallback callback; | 34 OutputCallback callback; |
| 35 | 35 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 66 // Gets called when output gets detected. | 66 // Gets called when output gets detected. |
| 67 void OnProcessOutput(int id, ProcessOutputType type, const std::string& data); | 67 void OnProcessOutput(int id, ProcessOutputType type, const std::string& data); |
| 68 | 68 |
| 69 bool EnsureWatcherThreadStarted(); | 69 bool EnsureWatcherThreadStarted(); |
| 70 | 70 |
| 71 // Map of all existing ProcessProxies. | 71 // Map of all existing ProcessProxies. |
| 72 std::map<int, ProcessProxyInfo> proxy_map_; | 72 std::map<int, ProcessProxyInfo> proxy_map_; |
| 73 | 73 |
| 74 std::unique_ptr<base::Thread> watcher_thread_; | 74 std::unique_ptr<base::Thread> watcher_thread_; |
| 75 | 75 |
| 76 SEQUENCE_CHECKER(sequence_checker_); |
| 77 |
| 76 DISALLOW_COPY_AND_ASSIGN(ProcessProxyRegistry); | 78 DISALLOW_COPY_AND_ASSIGN(ProcessProxyRegistry); |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 } // namespace chromeos | 81 } // namespace chromeos |
| 80 | 82 |
| 81 #endif // CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ | 83 #endif // CHROMEOS_PROCESS_PROXY_PROCESS_PROXY_REGISTRY_H_ |
| OLD | NEW |