Chromium Code Reviews| Index: headless/public/util/kv_map_protocol_handler.h |
| diff --git a/headless/public/util/kv_map_protocol_handler.h b/headless/public/util/kv_map_protocol_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..44515f7e2937ae4483e6a181922372f7c77fbf29 |
| --- /dev/null |
| +++ b/headless/public/util/kv_map_protocol_handler.h |
| @@ -0,0 +1,45 @@ |
| +// 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_TEST_TEST_PROTOCOL_HANDLER_H_ |
|
Sami
2016/06/27 11:10:42
Please update to match class name & location.
alex clarke (OOO till 29th)
2016/06/27 11:35:52
Done.
|
| +#define HEADLESS_TEST_TEST_PROTOCOL_HANDLER_H_ |
| + |
| +#include <map> |
| + |
| +#include "net/url_request/url_request_job_factory.h" |
| + |
| +namespace headless { |
| + |
| +class KVMapProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { |
|
Sami
2016/06/27 11:10:42
bikeshed: How about InMemoryProtocolHandler?
alex clarke (OOO till 29th)
2016/06/27 11:35:52
Done.
|
| + public: |
| + KVMapProtocolHandler(); |
| + ~KVMapProtocolHandler() 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(KVMapProtocolHandler); |
| +}; |
| + |
| +} // namespace headless |
| + |
| +#endif // HEADLESS_TEST_TEST_PROTOCOL_HANDLER_H_ |