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