Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: headless/public/util/black_hole_protocol_handler.cc

Issue 2049363003: Adds support for headless chrome embedder mojo services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #include "headless/public/util/black_hole_protocol_handler.h"
6
7 #include "base/threading/thread_task_runner_handle.h"
8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h"
10 #include "net/url_request/url_request_job.h"
11
12 namespace headless {
13 namespace {
14 class BlackHoleRequestJob : public net::URLRequestJob {
15 public:
16 BlackHoleRequestJob(net::URLRequest* request,
17 net::NetworkDelegate* network_delegate);
18
19 // net::URLRequestJob implementation:
20 void Start() override;
21 void Kill() override;
22
23 private:
24 ~BlackHoleRequestJob() override;
25
26 void StartAsync();
27
28 base::WeakPtrFactory<BlackHoleRequestJob> weak_factory_;
29
30 DISALLOW_COPY_AND_ASSIGN(BlackHoleRequestJob);
31 };
32
33 BlackHoleRequestJob::BlackHoleRequestJob(net::URLRequest* request,
34 net::NetworkDelegate* network_delegate)
35 : net::URLRequestJob(request, network_delegate), weak_factory_(this) {}
36
37 BlackHoleRequestJob::~BlackHoleRequestJob() {}
38
39 void BlackHoleRequestJob::Start() {
40 base::ThreadTaskRunnerHandle::Get()->PostTask(
41 FROM_HERE,
42 base::Bind(&BlackHoleRequestJob::StartAsync, weak_factory_.GetWeakPtr()));
43 }
44
45 void BlackHoleRequestJob::StartAsync() {
46 // Fail every request!
47 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
48 net::ERR_FILE_NOT_FOUND));
49 }
50
51 void BlackHoleRequestJob::Kill() {
52 weak_factory_.InvalidateWeakPtrs();
53 URLRequestJob::Kill();
54 }
55 } // namespace
56
57 BlackHoleProtocolHandler::BlackHoleProtocolHandler() {}
58 BlackHoleProtocolHandler::~BlackHoleProtocolHandler() {}
59
60 net::URLRequestJob* BlackHoleProtocolHandler::MaybeCreateJob(
61 net::URLRequest* request,
62 net::NetworkDelegate* network_delegate) const {
63 return new BlackHoleRequestJob(request, network_delegate);
64 }
65
66 } // namespace headless
OLDNEW
« no previous file with comments | « headless/public/util/black_hole_protocol_handler.h ('k') | headless/public/util/in_memory_protocol_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698