| 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 COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ | 5 #ifndef COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ |
| 6 #define COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ | 6 #define COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "components/nacl/browser/nacl_broker_host_win.h" | 15 #include "components/nacl/browser/nacl_broker_host_win.h" |
| 14 | 16 |
| 15 namespace nacl { | 17 namespace nacl { |
| 16 | 18 |
| 17 class NaClProcessHost; | 19 class NaClProcessHost; |
| 18 | 20 |
| 19 class NaClBrokerService { | 21 class NaClBrokerService { |
| 20 public: | 22 public: |
| 21 // Returns the NaClBrokerService singleton. | 23 // Returns the NaClBrokerService singleton. |
| 22 static NaClBrokerService* GetInstance(); | 24 static NaClBrokerService* GetInstance(); |
| 23 | 25 |
| 24 // Can be called several times, must be called before LaunchLoader. | 26 // Can be called several times, must be called before LaunchLoader. |
| 25 bool StartBroker(); | 27 bool StartBroker(); |
| 26 | 28 |
| 27 // Send a message to the broker process, causing it to launch | 29 // Send a message to the broker process, causing it to launch |
| 28 // a Native Client loader process. | 30 // a Native Client loader process. |
| 29 bool LaunchLoader(base::WeakPtr<NaClProcessHost> client, | 31 bool LaunchLoader(base::WeakPtr<NaClProcessHost> client, |
| 30 const std::string& loader_channel_id); | 32 const std::string& loader_channel_id); |
| 31 | 33 |
| 32 // Called by NaClBrokerHost to notify the service that a loader was launched. | 34 // Called by NaClBrokerHost to notify the service that a loader was launched. |
| 33 void OnLoaderLaunched(const std::string& channel_id, | 35 void OnLoaderLaunched(const std::string& channel_id, |
| 34 base::ProcessHandle handle); | 36 base::ProcessHandle handle); |
| 35 | 37 |
| 36 // Called by NaClProcessHost when a loader process is terminated | 38 // Called by NaClProcessHost when a loader process is terminated |
| 37 void OnLoaderDied(); | 39 void OnLoaderDied(); |
| 38 | 40 |
| 39 bool LaunchDebugExceptionHandler(base::WeakPtr<NaClProcessHost> client, | 41 bool LaunchDebugExceptionHandler(base::WeakPtr<NaClProcessHost> client, |
| 40 int32 pid, | 42 int32_t pid, |
| 41 base::ProcessHandle process_handle, | 43 base::ProcessHandle process_handle, |
| 42 const std::string& startup_info); | 44 const std::string& startup_info); |
| 43 | 45 |
| 44 // Called by NaClBrokerHost to notify the service that a debug | 46 // Called by NaClBrokerHost to notify the service that a debug |
| 45 // exception handler was started. | 47 // exception handler was started. |
| 46 void OnDebugExceptionHandlerLaunched(int32 pid, bool success); | 48 void OnDebugExceptionHandlerLaunched(int32_t pid, bool success); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 typedef std::map<std::string, base::WeakPtr<NaClProcessHost> > | 51 typedef std::map<std::string, base::WeakPtr<NaClProcessHost> > |
| 50 PendingLaunchesMap; | 52 PendingLaunchesMap; |
| 51 typedef std::map<int, base::WeakPtr<NaClProcessHost> > | 53 typedef std::map<int, base::WeakPtr<NaClProcessHost> > |
| 52 PendingDebugExceptionHandlersMap; | 54 PendingDebugExceptionHandlersMap; |
| 53 | 55 |
| 54 friend struct base::DefaultSingletonTraits<NaClBrokerService>; | 56 friend struct base::DefaultSingletonTraits<NaClBrokerService>; |
| 55 | 57 |
| 56 NaClBrokerService(); | 58 NaClBrokerService(); |
| 57 ~NaClBrokerService(); | 59 ~NaClBrokerService(); |
| 58 | 60 |
| 59 NaClBrokerHost* GetBrokerHost(); | 61 NaClBrokerHost* GetBrokerHost(); |
| 60 | 62 |
| 61 int loaders_running_; | 63 int loaders_running_; |
| 62 PendingLaunchesMap pending_launches_; | 64 PendingLaunchesMap pending_launches_; |
| 63 PendingDebugExceptionHandlersMap pending_debuggers_; | 65 PendingDebugExceptionHandlersMap pending_debuggers_; |
| 64 | 66 |
| 65 DISALLOW_COPY_AND_ASSIGN(NaClBrokerService); | 67 DISALLOW_COPY_AND_ASSIGN(NaClBrokerService); |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 } // namespace nacl | 70 } // namespace nacl |
| 69 | 71 |
| 70 #endif // COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ | 72 #endif // COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_ |
| OLD | NEW |