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

Side by Side Diff: ios/web/public/test/response_providers/response_provider.h

Issue 2898733003: Split up ios/web:test_support. (Closed)
Patch Set: don't break downstream clients Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_
6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "net/http/http_request_headers.h"
14 #include "net/http/http_response_headers.h"
15 #include "net/http/http_status_code.h"
16 #include "url/gurl.h"
17
18 @class GCDWebServerResponse;
19
20 namespace web {
21
22 // An abstract class for a provider that services a request and returns a
23 // GCDWebServerResponse.
24 // Note: The ResponseProviders can be called from any arbitrary GCD thread.
25 class ResponseProvider {
26 public:
27 // A data structure that encapsulated all the fields of a request.
28 struct Request {
29 Request(const GURL& url,
30 const std::string& method,
31 const std::string& body,
32 const net::HttpRequestHeaders& headers);
33 Request(const Request& other);
34 virtual ~Request();
35
36 // The URL for the request.
37 GURL url;
38 // The HTTP method for the request such as "GET" or "POST".
39 std::string method;
40 // The body of the request.
41 std::string body;
42 // The HTTP headers for the request.
43 net::HttpRequestHeaders headers;
44 };
45
46 // Returns true if the request is handled by the provider.
47 virtual bool CanHandleRequest(const Request& request) = 0;
48
49 // Returns the GCDWebServerResponse as a reply to the request. Will only be
50 // called if the provider can handle the request.
51 virtual GCDWebServerResponse* GetGCDWebServerResponse(
52 const Request& request) = 0;
53
54 // Gets default response headers with a text/html content type and a 200
55 // response code.
56 static scoped_refptr<net::HttpResponseHeaders> GetDefaultResponseHeaders();
57 // Gets a map of response headers with a text/html content type, a 200
58 // response code and Set-Cookie in headers.
59 static std::map<GURL, scoped_refptr<net::HttpResponseHeaders>>
60 GetDefaultResponseHeaders(
61 const std::map<GURL, std::pair<std::string, std::string>>& responses);
62 // Gets configurable response headers with a provided content type and a
63 // 200 response code.
64 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders(
65 const std::string& content_type);
66 // Gets configurable response headers with a provided content type and
67 // response code.
68 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders(
69 const std::string& content_type,
70 net::HttpStatusCode response_code);
71 // Gets configurable response based on |http_status| headers for redirecting
72 // to |destination|.
73 static scoped_refptr<net::HttpResponseHeaders> GetRedirectResponseHeaders(
74 const std::string& destination,
75 const net::HttpStatusCode& http_status);
76
77 ResponseProvider();
78 virtual ~ResponseProvider() {};
79 private:
80 DISALLOW_COPY_AND_ASSIGN(ResponseProvider);
81 };
82
83 } // namspace web
84
85 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698