forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context_provider_impl.h
71 lines (52 loc) · 2.25 KB
/
context_provider_impl.h
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
71
// Copyright 2018 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 WEBRUNNER_SERVICE_CONTEXT_PROVIDER_IMPL_H_
#define WEBRUNNER_SERVICE_CONTEXT_PROVIDER_IMPL_H_
#include <lib/fidl/cpp/binding_set.h>
#include <memory>
#include "base/callback.h"
#include "base/macros.h"
#include "chromium/web/cpp/fidl.h"
#include "webrunner/common/webrunner_export.h"
namespace base {
class CommandLine;
struct LaunchOptions;
class Process;
} // namespace base
namespace webrunner {
class WEBRUNNER_EXPORT ContextProviderImpl
: public chromium::web::ContextProvider {
public:
ContextProviderImpl();
~ContextProviderImpl() override;
// Creates a ContextProviderImpl that shares its /tmp directory with its child
// processes. This is useful for GTest processes, which depend on a shared
// tmpdir for storing startup flags and retrieving test result files.
static std::unique_ptr<ContextProviderImpl> CreateForTest();
// Binds |this| object instance to |request|.
// The service will persist and continue to serve other channels in the event
// that a bound channel is dropped.
void Bind(fidl::InterfaceRequest<chromium::web::ContextProvider> request);
// chromium::web::ContextProvider implementation.
void Create(chromium::web::CreateContextParams params,
::fidl::InterfaceRequest<chromium::web::Context> context_request)
override;
private:
using LaunchContextProcessCallback = base::RepeatingCallback<base::Process(
const base::CommandLine& command,
const base::LaunchOptions& options)>;
friend class ContextProviderImplTest;
explicit ContextProviderImpl(bool use_shared_tmp);
// Overrides the default child process launching logic to call |launch|
// instead.
void SetLaunchCallbackForTests(const LaunchContextProcessCallback& launch);
// Spawns a Context child process.
LaunchContextProcessCallback launch_;
// If set, then the ContextProvider will share /tmp with its child processes.
bool use_shared_tmp_ = true;
fidl::BindingSet<chromium::web::ContextProvider> bindings_;
DISALLOW_COPY_AND_ASSIGN(ContextProviderImpl);
};
} // namespace webrunner
#endif // WEBRUNNER_SERVICE_CONTEXT_PROVIDER_IMPL_H_