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

Side by Side Diff: headless/public/util/in_memory_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/in_memory_protocol_handler.h"
6
7 #include "headless/public/util/in_memory_request_job.h"
8
9 namespace headless {
10
11 InMemoryProtocolHandler::InMemoryProtocolHandler() {}
12 InMemoryProtocolHandler::~InMemoryProtocolHandler() {}
13
14 net::URLRequestJob* InMemoryProtocolHandler::MaybeCreateJob(
15 net::URLRequest* request,
16 net::NetworkDelegate* network_delegate) const {
17 return new InMemoryRequestJob(request, network_delegate,
18 GetResponse(request->url().GetContent()));
19 }
20
21 void InMemoryProtocolHandler::InsertResponse(const std::string& request_path,
22 const Response& response) {
23 // GURL::GetContent excludes the scheme and : but includes the // prefix. As a
24 // convenience we add it here.
25 response_map_["//" + request_path] = response;
26 }
27
28 const InMemoryProtocolHandler::Response* InMemoryProtocolHandler::GetResponse(
29 const std::string& request_path) const {
30 std::map<std::string, Response>::const_iterator find_it =
31 response_map_.find(request_path);
32 if (find_it == response_map_.end())
33 return nullptr;
34 return &find_it->second;
35 }
36
37 } // namespace headless
OLDNEW
« no previous file with comments | « headless/public/util/in_memory_protocol_handler.h ('k') | headless/public/util/in_memory_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698