OLD | NEW |
---|---|
(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 #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.
| |
6 #define HEADLESS_TEST_TEST_PROTOCOL_HANDLER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "net/url_request/url_request_job_factory.h" | |
11 | |
12 namespace headless { | |
13 | |
14 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.
| |
15 public: | |
16 KVMapProtocolHandler(); | |
17 ~KVMapProtocolHandler() override; | |
18 | |
19 net::URLRequestJob* MaybeCreateJob( | |
20 net::URLRequest* request, | |
21 net::NetworkDelegate* network_delegate) const override; | |
22 | |
23 struct Response { | |
24 Response() {} | |
25 Response(const std::string& data, const std::string& mime_type) | |
26 : data(data), mime_type(mime_type) {} | |
27 | |
28 std::string data; | |
29 std::string mime_type; | |
30 }; | |
31 | |
32 void InsertResponse(const std::string& request_path, | |
33 const Response& response); | |
34 | |
35 private: | |
36 const Response* GetResponse(const std::string& request_path) const; | |
37 | |
38 std::map<std::string, Response> response_map_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(KVMapProtocolHandler); | |
41 }; | |
42 | |
43 } // namespace headless | |
44 | |
45 #endif // HEADLESS_TEST_TEST_PROTOCOL_HANDLER_H_ | |
OLD | NEW |