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

Unified Diff: headless/public/util/kv_map_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: Abandon (for now) the concice bindings. Add BINDINGS_POLICY_HEADLESS and headless-mojo:// Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: headless/public/util/kv_map_protocol_handler.cc
diff --git a/headless/public/util/kv_map_protocol_handler.cc b/headless/public/util/kv_map_protocol_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2da192dbc845e0d474f2641f4542d4471232abd3
--- /dev/null
+++ b/headless/public/util/kv_map_protocol_handler.cc
@@ -0,0 +1,37 @@
+// Copyright 2016 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.
+
+#include "headless/public/util/kv_map_protocol_handler.h"
+
+#include "headless/public/util/kv_map_request_job.h"
+
+namespace headless {
+
+KVMapProtocolHandler::KVMapProtocolHandler() {}
+KVMapProtocolHandler::~KVMapProtocolHandler() {}
+
+net::URLRequestJob* KVMapProtocolHandler::MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ return new KVMapRequestJob(request, network_delegate,
+ GetResponse(request->url().GetContent()));
+}
+
+void KVMapProtocolHandler::InsertResponse(const std::string& request_path,
+ const Response& response) {
+ // GURL::GetContent excludes the scheme and : but includes the // prefix. As a
+ // convenience we add it here.
+ response_map_["//" + request_path] = response;
+}
+
+const KVMapProtocolHandler::Response* KVMapProtocolHandler::GetResponse(
+ const std::string& request_path) const {
+ std::map<std::string, Response>::const_iterator find_it =
+ response_map_.find(request_path);
+ if (find_it == response_map_.end())
+ return nullptr;
+ return &find_it->second;
+}
+
+} // namespace headless

Powered by Google App Engine
This is Rietveld 408576698