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.
5 #ifndef CHROME_BROWSER_NACL_HOST_NACL_BROKER_SERVICE_WIN_H_
6 #define CHROME_BROWSER_NACL_HOST_NACL_BROKER_SERVICE_WIN_H_
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"
15 class NaClProcessHost;
17 class NaClBrokerService {
19 // Returns the NaClBrokerService singleton.
20 static NaClBrokerService* GetInstance();
22 // Can be called several times, must be called before LaunchLoader.
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);
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);
34 // Called by NaClProcessHost when a loader process is terminated
37 bool LaunchDebugExceptionHandler(base::WeakPtr<NaClProcessHost> client,
39 base::ProcessHandle process_handle,
40 const std::string& startup_info);
42 // Called by NaClBrokerHost to notify the service that a debug
43 // exception handler was started.
44 void OnDebugExceptionHandlerLaunched(int32 pid, bool success);
47 typedef std::map<std::string, base::WeakPtr<NaClProcessHost> >
49 typedef std::map<int, base::WeakPtr<NaClProcessHost> >
50 PendingDebugExceptionHandlersMap;
52 friend struct DefaultSingletonTraits<NaClBrokerService>;
55 ~NaClBrokerService() {}
57 NaClBrokerHost* GetBrokerHost();
60 PendingLaunchesMap pending_launches_;
61 PendingDebugExceptionHandlersMap pending_debuggers_;
63 DISALLOW_COPY_AND_ASSIGN(NaClBrokerService);
66 #endif // CHROME_BROWSER_NACL_HOST_NACL_BROKER_SERVICE_WIN_H_