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

Unified Diff: headless/public/util/in_memory_protocol_handler.h

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, 5 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/in_memory_protocol_handler.h
diff --git a/headless/public/util/in_memory_protocol_handler.h b/headless/public/util/in_memory_protocol_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d69d46a9b24d47e99799d8ecb3e9ff63944adf2
--- /dev/null
+++ b/headless/public/util/in_memory_protocol_handler.h
@@ -0,0 +1,46 @@
+// 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.
+
+#ifndef HEADLESS_PUBLIC_UTIL_IN_MEMORY_PROTOCOL_HANDLER_H_
+#define HEADLESS_PUBLIC_UTIL_IN_MEMORY_PROTOCOL_HANDLER_H_
+
+#include <map>
+
+#include "net/url_request/url_request_job_factory.h"
+
+namespace headless {
+
+class InMemoryProtocolHandler
+ : public net::URLRequestJobFactory::ProtocolHandler {
+ public:
+ InMemoryProtocolHandler();
+ ~InMemoryProtocolHandler() override;
+
+ net::URLRequestJob* MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const override;
+
+ struct Response {
+ Response() {}
+ Response(const std::string& data, const std::string& mime_type)
+ : data(data), mime_type(mime_type) {}
+
+ std::string data;
+ std::string mime_type;
+ };
+
+ void InsertResponse(const std::string& request_path,
+ const Response& response);
+
+ private:
+ const Response* GetResponse(const std::string& request_path) const;
+
+ std::map<std::string, Response> response_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(InMemoryProtocolHandler);
+};
+
+} // namespace headless
+
+#endif // HEADLESS_PUBLIC_UTIL_IN_MEMORY_PROTOCOL_HANDLER_H_
« no previous file with comments | « headless/public/util/black_hole_protocol_handler.cc ('k') | headless/public/util/in_memory_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698