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

Side by Side Diff: net/test/embedded_test_server/request_handler_util.h

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_ 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_
6 #define NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_ 6 #define NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h" 16 #include "net/test/embedded_test_server/embedded_test_server.h"
17 #include "net/test/embedded_test_server/http_response.h" 17 #include "net/test/embedded_test_server/http_response.h"
18 18
19 namespace url { 19 namespace url {
20 class GURL; 20 class GURL;
21 } 21 }
22 22
23 namespace net { 23 namespace net {
24 namespace test_server { 24 namespace test_server {
25 struct HttpRequest; 25 struct HttpRequest;
26 26
27 // This file is only meant for compatibility with testserver.py. No 27 // This file is only meant for compatibility with testserver.py. No
28 // additional handlers should be added here that don't affect multiple 28 // additional handlers should be added here that don't affect multiple
29 // distinct tests. 29 // distinct tests.
30 30
31 using RequestQuery = std::map<std::string, std::vector<std::string>>; 31 using RequestQuery = std::map<std::string, std::vector<std::string>>;
32 32
33 // Return whether |request| starts with a URL path of |url|. 33 // Return whether |request| starts with a URL path of |url|.
34 bool ShouldHandle(const HttpRequest& request, const std::string& prefix_path); 34 bool ShouldHandle(const HttpRequest& request, const std::string& prefix_path);
35 35
36 // Calls |handler| if the |request| URL starts with |prefix|. 36 // Calls |handler| if the |request| URL starts with |prefix|.
37 scoped_ptr<HttpResponse> HandlePrefixedRequest( 37 std::unique_ptr<HttpResponse> HandlePrefixedRequest(
38 const std::string& prefix, 38 const std::string& prefix,
39 const EmbeddedTestServer::HandleRequestCallback& handler, 39 const EmbeddedTestServer::HandleRequestCallback& handler,
40 const HttpRequest& request); 40 const HttpRequest& request);
41 41
42 // Parses |url| to get the query and places it into a map. 42 // Parses |url| to get the query and places it into a map.
43 RequestQuery ParseQuery(const GURL& url); 43 RequestQuery ParseQuery(const GURL& url);
44 44
45 // Returns a path that serves the contents of the file at |original_path| 45 // Returns a path that serves the contents of the file at |original_path|
46 // with all the text matching the elements of |text_to_replace| replaced 46 // with all the text matching the elements of |text_to_replace| replaced
47 // with the corresponding values. The path is returned in |replacement_path|. 47 // with the corresponding values. The path is returned in |replacement_path|.
48 // The result path is only usable by HandleFileRequest which will perform the 48 // The result path is only usable by HandleFileRequest which will perform the
49 // actual replacements of the file contents. 49 // actual replacements of the file contents.
50 // TODO(svaldez): Modify to return |replacement_path| instead of passing by 50 // TODO(svaldez): Modify to return |replacement_path| instead of passing by
51 // reference. 51 // reference.
52 void GetFilePathWithReplacements(const std::string& original_path, 52 void GetFilePathWithReplacements(const std::string& original_path,
53 const base::StringPairs& text_to_replace, 53 const base::StringPairs& text_to_replace,
54 std::string* replacement_path); 54 std::string* replacement_path);
55 55
56 // Handles |request| by serving a file from under |server_root|. 56 // Handles |request| by serving a file from under |server_root|.
57 scoped_ptr<HttpResponse> HandleFileRequest(const base::FilePath& server_root, 57 std::unique_ptr<HttpResponse> HandleFileRequest(
58 const HttpRequest& request); 58 const base::FilePath& server_root,
59 const HttpRequest& request);
59 60
60 } // namespace test_server 61 } // namespace test_server
61 } // namespace net 62 } // namespace net
62 63
63 #endif // NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_ 64 #endif // NET_TEST_EMBEDDED_TEST_SERVER_REQUEST_HANDLER_UTIL_H_
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/http_request_unittest.cc ('k') | net/test/embedded_test_server/request_handler_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698