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

Side by Side Diff: chrome/browser/extensions/extension_apitest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 26 matching lines...) Expand all
37 37
38 namespace { 38 namespace {
39 39
40 const char kTestCustomArg[] = "customArg"; 40 const char kTestCustomArg[] = "customArg";
41 const char kTestDataDirectory[] = "testDataDirectory"; 41 const char kTestDataDirectory[] = "testDataDirectory";
42 const char kTestWebSocketPort[] = "testWebSocketPort"; 42 const char kTestWebSocketPort[] = "testWebSocketPort";
43 const char kIsolateExtensions[] = "isolateExtensions"; 43 const char kIsolateExtensions[] = "isolateExtensions";
44 const char kFtpServerPort[] = "ftpServer.port"; 44 const char kFtpServerPort[] = "ftpServer.port";
45 const char kEmbeddedTestServerPort[] = "testServer.port"; 45 const char kEmbeddedTestServerPort[] = "testServer.port";
46 46
47 scoped_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest( 47 std::unique_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest(
48 const net::test_server::HttpRequest& request) { 48 const net::test_server::HttpRequest& request) {
49 if (!base::StartsWith(request.relative_url, "/server-redirect?", 49 if (!base::StartsWith(request.relative_url, "/server-redirect?",
50 base::CompareCase::SENSITIVE)) 50 base::CompareCase::SENSITIVE))
51 return nullptr; 51 return nullptr;
52 52
53 size_t query_string_pos = request.relative_url.find('?'); 53 size_t query_string_pos = request.relative_url.find('?');
54 std::string redirect_target = 54 std::string redirect_target =
55 request.relative_url.substr(query_string_pos + 1); 55 request.relative_url.substr(query_string_pos + 1);
56 56
57 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 57 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
58 new net::test_server::BasicHttpResponse); 58 new net::test_server::BasicHttpResponse);
59 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); 59 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
60 http_response->AddCustomHeader("Location", redirect_target); 60 http_response->AddCustomHeader("Location", redirect_target);
61 return std::move(http_response); 61 return std::move(http_response);
62 } 62 }
63 63
64 scoped_ptr<net::test_server::HttpResponse> HandleEchoHeaderRequest( 64 std::unique_ptr<net::test_server::HttpResponse> HandleEchoHeaderRequest(
65 const net::test_server::HttpRequest& request) { 65 const net::test_server::HttpRequest& request) {
66 if (!base::StartsWith(request.relative_url, "/echoheader?", 66 if (!base::StartsWith(request.relative_url, "/echoheader?",
67 base::CompareCase::SENSITIVE)) 67 base::CompareCase::SENSITIVE))
68 return nullptr; 68 return nullptr;
69 69
70 size_t query_string_pos = request.relative_url.find('?'); 70 size_t query_string_pos = request.relative_url.find('?');
71 std::string header_name = 71 std::string header_name =
72 request.relative_url.substr(query_string_pos + 1); 72 request.relative_url.substr(query_string_pos + 1);
73 73
74 std::string header_value; 74 std::string header_value;
75 auto it = request.headers.find(header_name); 75 auto it = request.headers.find(header_name);
76 if (it != request.headers.end()) 76 if (it != request.headers.end())
77 header_value = it->second; 77 header_value = it->second;
78 78
79 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 79 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
80 new net::test_server::BasicHttpResponse); 80 new net::test_server::BasicHttpResponse);
81 http_response->set_code(net::HTTP_OK); 81 http_response->set_code(net::HTTP_OK);
82 http_response->set_content(header_value); 82 http_response->set_content(header_value);
83 return std::move(http_response); 83 return std::move(http_response);
84 } 84 }
85 85
86 scoped_ptr<net::test_server::HttpResponse> HandleSetCookieRequest( 86 std::unique_ptr<net::test_server::HttpResponse> HandleSetCookieRequest(
87 const net::test_server::HttpRequest& request) { 87 const net::test_server::HttpRequest& request) {
88 if (!base::StartsWith(request.relative_url, "/set-cookie?", 88 if (!base::StartsWith(request.relative_url, "/set-cookie?",
89 base::CompareCase::SENSITIVE)) 89 base::CompareCase::SENSITIVE))
90 return nullptr; 90 return nullptr;
91 91
92 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 92 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
93 new net::test_server::BasicHttpResponse); 93 new net::test_server::BasicHttpResponse);
94 http_response->set_code(net::HTTP_OK); 94 http_response->set_code(net::HTTP_OK);
95 95
96 size_t query_string_pos = request.relative_url.find('?'); 96 size_t query_string_pos = request.relative_url.find('?');
97 std::string cookie_value = 97 std::string cookie_value =
98 request.relative_url.substr(query_string_pos + 1); 98 request.relative_url.substr(query_string_pos + 1);
99 99
100 for (const std::string& cookie : base::SplitString( 100 for (const std::string& cookie : base::SplitString(
101 cookie_value, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) 101 cookie_value, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
102 http_response->AddCustomHeader("Set-Cookie", cookie); 102 http_response->AddCustomHeader("Set-Cookie", cookie);
103 103
104 return std::move(http_response); 104 return std::move(http_response);
105 } 105 }
106 106
107 scoped_ptr<net::test_server::HttpResponse> HandleSetHeaderRequest( 107 std::unique_ptr<net::test_server::HttpResponse> HandleSetHeaderRequest(
108 const net::test_server::HttpRequest& request) { 108 const net::test_server::HttpRequest& request) {
109 if (!base::StartsWith(request.relative_url, "/set-header?", 109 if (!base::StartsWith(request.relative_url, "/set-header?",
110 base::CompareCase::SENSITIVE)) 110 base::CompareCase::SENSITIVE))
111 return nullptr; 111 return nullptr;
112 112
113 size_t query_string_pos = request.relative_url.find('?'); 113 size_t query_string_pos = request.relative_url.find('?');
114 std::string escaped_header = 114 std::string escaped_header =
115 request.relative_url.substr(query_string_pos + 1); 115 request.relative_url.substr(query_string_pos + 1);
116 116
117 std::string header = net::UnescapeURLComponent( 117 std::string header = net::UnescapeURLComponent(
118 escaped_header, 118 escaped_header,
119 net::UnescapeRule::NORMAL | net::UnescapeRule::SPACES | 119 net::UnescapeRule::NORMAL | net::UnescapeRule::SPACES |
120 net::UnescapeRule::PATH_SEPARATORS | 120 net::UnescapeRule::PATH_SEPARATORS |
121 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); 121 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS);
122 122
123 size_t colon_pos = header.find(':'); 123 size_t colon_pos = header.find(':');
124 if (colon_pos == std::string::npos) 124 if (colon_pos == std::string::npos)
125 return scoped_ptr<net::test_server::HttpResponse>(); 125 return std::unique_ptr<net::test_server::HttpResponse>();
126 126
127 std::string header_name = header.substr(0, colon_pos); 127 std::string header_name = header.substr(0, colon_pos);
128 // Skip space after colon. 128 // Skip space after colon.
129 std::string header_value = header.substr(colon_pos + 2); 129 std::string header_value = header.substr(colon_pos + 2);
130 130
131 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 131 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
132 new net::test_server::BasicHttpResponse); 132 new net::test_server::BasicHttpResponse);
133 http_response->set_code(net::HTTP_OK); 133 http_response->set_code(net::HTTP_OK);
134 http_response->AddCustomHeader(header_name, header_value); 134 http_response->AddCustomHeader(header_name, header_value);
135 return std::move(http_response); 135 return std::move(http_response);
136 } 136 }
137 137
138 }; // namespace 138 }; // namespace
139 139
140 ExtensionApiTest::ExtensionApiTest() { 140 ExtensionApiTest::ExtensionApiTest() {
141 embedded_test_server()->RegisterRequestHandler( 141 embedded_test_server()->RegisterRequestHandler(
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 void ExtensionApiTest::SetUpCommandLine(base::CommandLine* command_line) { 428 void ExtensionApiTest::SetUpCommandLine(base::CommandLine* command_line) {
429 ExtensionBrowserTest::SetUpCommandLine(command_line); 429 ExtensionBrowserTest::SetUpCommandLine(command_line);
430 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); 430 test_data_dir_ = test_data_dir_.AppendASCII("api_test");
431 // Backgrounded renderer processes run at a lower priority, causing the 431 // Backgrounded renderer processes run at a lower priority, causing the
432 // tests to take more time to complete. Disable backgrounding so that the 432 // tests to take more time to complete. Disable backgrounding so that the
433 // tests don't time out. 433 // tests don't time out.
434 command_line->AppendSwitch(switches::kDisableRendererBackgrounding); 434 command_line->AppendSwitch(switches::kDisableRendererBackgrounding);
435 } 435 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_app_icon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698