QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / components / nacl / browser / nacl_broker_service_win.h
blob861057874cd616722c8ada64b8025c8d39746571
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_
8 #include <map>
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"
15 namespace nacl {
17 class NaClProcessHost;
19 class NaClBrokerService {
20 public:
21 // Returns the NaClBrokerService singleton.
22 static NaClBrokerService* GetInstance();
24 // Can be called several times, must be called before LaunchLoader.
25 bool StartBroker();
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
37 void OnLoaderDied();
39 bool LaunchDebugExceptionHandler(base::WeakPtr<NaClProcessHost> client,
40 int32 pid,
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);
48 private:
49 typedef std::map<std::string, base::WeakPtr<NaClProcessHost> >
50 PendingLaunchesMap;
51 typedef std::map<int, base::WeakPtr<NaClProcessHost> >
52 PendingDebugExceptionHandlersMap;
54 friend struct DefaultSingletonTraits<NaClBrokerService>;
56 NaClBrokerService();
57 ~NaClBrokerService();
59 NaClBrokerHost* GetBrokerHost();
61 int loaders_running_;
62 PendingLaunchesMap pending_launches_;
63 PendingDebugExceptionHandlersMap pending_debuggers_;
65 DISALLOW_COPY_AND_ASSIGN(NaClBrokerService);
68 } // namespace nacl
70 #endif // COMPONENTS_NACL_BROWSER_NACL_BROKER_SERVICE_WIN_H_