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