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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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 #include <utility>
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/profiles/profile_io_data.h" 12 #include "chrome/browser/profiles/profile_io_data.h"
11 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
12 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
13 #include "extensions/browser/extension_throttle_manager.h" 15 #include "extensions/browser/extension_throttle_manager.h"
14 #include "extensions/test/result_catcher.h" 16 #include "extensions/test/result_catcher.h"
(...skipping 15 matching lines...) Expand all
30 if (base::StartsWith(request.relative_url, "/redirect", 32 if (base::StartsWith(request.relative_url, "/redirect",
31 base::CompareCase::SENSITIVE)) { 33 base::CompareCase::SENSITIVE)) {
32 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 34 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
33 new net::test_server::BasicHttpResponse()); 35 new net::test_server::BasicHttpResponse());
34 http_response->set_code(net::HTTP_FOUND); 36 http_response->set_code(net::HTTP_FOUND);
35 http_response->set_content("Redirecting..."); 37 http_response->set_content("Redirecting...");
36 http_response->set_content_type("text/plain"); 38 http_response->set_content_type("text/plain");
37 http_response->AddCustomHeader("Location", "/test_throttle"); 39 http_response->AddCustomHeader("Location", "/test_throttle");
38 if (set_cache_header_redirect_page) 40 if (set_cache_header_redirect_page)
39 http_response->AddCustomHeader("Cache-Control", "max-age=3600"); 41 http_response->AddCustomHeader("Cache-Control", "max-age=3600");
40 return http_response.Pass(); 42 return std::move(http_response);
41 } 43 }
42 44
43 if (base::StartsWith(request.relative_url, "/test_throttle", 45 if (base::StartsWith(request.relative_url, "/test_throttle",
44 base::CompareCase::SENSITIVE)) { 46 base::CompareCase::SENSITIVE)) {
45 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 47 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
46 new net::test_server::BasicHttpResponse()); 48 new net::test_server::BasicHttpResponse());
47 http_response->set_code(net::HTTP_SERVICE_UNAVAILABLE); 49 http_response->set_code(net::HTTP_SERVICE_UNAVAILABLE);
48 http_response->set_content("The server is overloaded right now."); 50 http_response->set_content("The server is overloaded right now.");
49 http_response->set_content_type("text/plain"); 51 http_response->set_content_type("text/plain");
50 if (set_cache_header_test_throttle_page) 52 if (set_cache_header_test_throttle_page)
51 http_response->AddCustomHeader("Cache-Control", "max-age=3600"); 53 http_response->AddCustomHeader("Cache-Control", "max-age=3600");
52 return http_response.Pass(); 54 return std::move(http_response);
53 } 55 }
54 56
55 // Unhandled requests result in the Embedded test server sending a 404. 57 // Unhandled requests result in the Embedded test server sending a 404.
56 return scoped_ptr<net::test_server::BasicHttpResponse>(); 58 return scoped_ptr<net::test_server::BasicHttpResponse>();
57 } 59 }
58 60
59 } // namespace 61 } // namespace
60 62
61 class ExtensionRequestLimitingThrottleBrowserTest 63 class ExtensionRequestLimitingThrottleBrowserTest
62 : public ExtensionBrowserTest { 64 : public ExtensionBrowserTest {
(...skipping 29 matching lines...) Expand all
92 // Maximum amount of time we are willing to delay our request in ms. 94 // Maximum amount of time we are willing to delay our request in ms.
93 15 * 60 * 1000, 95 15 * 60 * 1000,
94 96
95 // Time to keep an entry from being discarded even when it 97 // Time to keep an entry from being discarded even when it
96 // has no significant state, -1 to never discard. 98 // has no significant state, -1 to never discard.
97 -1, 99 -1,
98 100
99 // Don't use initial delay unless the last request was an error. 101 // Don't use initial delay unless the last request was an error.
100 false, 102 false,
101 }); 103 });
102 manager->SetBackoffPolicyForTests(policy.Pass()); 104 manager->SetBackoffPolicyForTests(std::move(policy));
103 } 105 }
104 // Requests to 127.0.0.1 bypass throttling, so set up a host resolver rule 106 // Requests to 127.0.0.1 bypass throttling, so set up a host resolver rule
105 // to use a fake domain. 107 // to use a fake domain.
106 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 108 host_resolver()->AddRule("www.example.com", "127.0.0.1");
107 ASSERT_TRUE(embedded_test_server()->Start()); 109 ASSERT_TRUE(embedded_test_server()->Start());
108 extension_ = 110 extension_ =
109 LoadExtension(test_data_dir_.AppendASCII("extension_throttle")); 111 LoadExtension(test_data_dir_.AppendASCII("extension_throttle"));
110 ASSERT_TRUE(extension_); 112 ASSERT_TRUE(extension_);
111 } 113 }
112 114
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 ThrottleRequestDisabled) { 233 ThrottleRequestDisabled) {
232 embedded_test_server()->RegisterRequestHandler( 234 embedded_test_server()->RegisterRequestHandler(
233 base::Bind(&HandleRequest, false, false)); 235 base::Bind(&HandleRequest, false, false));
234 ASSERT_NO_FATAL_FAILURE( 236 ASSERT_NO_FATAL_FAILURE(
235 RunTest("test_request_not_throttled.html", 237 RunTest("test_request_not_throttled.html",
236 base::StringPrintf("http://www.example.com:%d/test_throttle", 238 base::StringPrintf("http://www.example.com:%d/test_throttle",
237 embedded_test_server()->port()))); 239 embedded_test_server()->port())));
238 } 240 }
239 241
240 } // namespace extensions 242 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_migrator.cc ('k') | chrome/browser/extensions/extension_service_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698