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 COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_
6 #define COMPONENTS_NACL_BROWSER_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 "components/nacl/browser/nacl_broker_host_win.h"
17 class NaClProcessHost
;
19 class NaClBrokerService
{
21 // Returns the NaClBrokerService singleton.
22 static NaClBrokerService
* GetInstance();
24 // Can be called several times, must be called before LaunchLoader.
27 // Send a message to the broker process, causing it to launch
28 // a Native Client loader process.
29 bool LaunchLoader(base::WeakPtr
<NaClProcessHost
> client
,
30 const std::string
& loader_channel_id
);
32 // Called by NaClBrokerHost to notify the service that a loader was launched.
33 void OnLoaderLaunched(const std::string
& channel_id
,
34 base::ProcessHandle handle
);
36 // Called by NaClProcessHost when a loader process is terminated
39 bool LaunchDebugExceptionHandler(base::WeakPtr
<NaClProcessHost
> client
,
41 base::ProcessHandle process_handle
,
42 const std::string
& startup_info
);
44 // Called by NaClBrokerHost to notify the service that a debug
45 // exception handler was started.
46 void OnDebugExceptionHandlerLaunched(int32 pid
, bool success
);
49 typedef std::map
<std::string
, base::WeakPtr
<NaClProcessHost
> >
51 typedef std::map
<int, base::WeakPtr
<NaClProcessHost
> >
52 PendingDebugExceptionHandlersMap
;
54 friend struct DefaultSingletonTraits
<NaClBrokerService
>;
59 NaClBrokerHost
* GetBrokerHost();
62 PendingLaunchesMap pending_launches_
;
63 PendingDebugExceptionHandlersMap pending_debuggers_
;
65 DISALLOW_COPY_AND_ASSIGN(NaClBrokerService
);
70 #endif // COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_