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

Side by Side Diff: chrome/browser/prerender/prerender_tracker_unittest.cc

Issue 398903002: Plumb redirect info out of net, through content, and into child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: darin comments Created 6 years, 4 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 | Annotate | Revision Log
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 <set> 5 #include <set>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
13 #include "chrome/browser/net/url_request_mock_util.h" 13 #include "chrome/browser/net/url_request_mock_util.h"
14 #include "chrome/browser/prerender/prerender_contents.h" 14 #include "chrome/browser/prerender/prerender_contents.h"
15 #include "chrome/browser/prerender/prerender_manager.h" 15 #include "chrome/browser/prerender/prerender_manager.h"
16 #include "chrome/browser/prerender/prerender_resource_throttle.h" 16 #include "chrome/browser/prerender/prerender_resource_throttle.h"
17 #include "chrome/browser/prerender/prerender_tracker.h" 17 #include "chrome/browser/prerender/prerender_tracker.h"
18 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
19 #include "content/public/browser/resource_controller.h" 19 #include "content/public/browser/resource_controller.h"
20 #include "content/public/browser/resource_request_info.h" 20 #include "content/public/browser/resource_request_info.h"
21 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
22 #include "content/test/net/url_request_mock_http_job.h" 22 #include "content/test/net/url_request_mock_http_job.h"
23 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
24 #include "net/base/request_priority.h" 24 #include "net/base/request_priority.h"
25 #include "net/url_request/redirect_info.h"
25 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
26 #include "net/url_request/url_request_test_util.h" 27 #include "net/url_request/url_request_test_util.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
29 using content::BrowserThread; 30 using content::BrowserThread;
30 using content::ResourceType; 31 using content::ResourceType;
31 32
32 namespace prerender { 33 namespace prerender {
33 34
34 namespace { 35 namespace {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 run_loop_.reset(new base::RunLoop()); 113 run_loop_.reset(new base::RunLoop());
113 run_loop_->Run(); 114 run_loop_->Run();
114 } 115 }
115 116
116 bool was_deferred() const { return was_deferred_; } 117 bool was_deferred() const { return was_deferred_; }
117 bool cancel_called() const { return cancel_called_; } 118 bool cancel_called() const { return cancel_called_; }
118 bool resume_called() const { return resume_called_; } 119 bool resume_called() const { return resume_called_; }
119 120
120 // net::URLRequest::Delegate implementation: 121 // net::URLRequest::Delegate implementation:
121 virtual void OnReceivedRedirect(net::URLRequest* request, 122 virtual void OnReceivedRedirect(net::URLRequest* request,
122 const GURL& new_url, 123 const net::RedirectInfo& redirect_info,
123 bool* defer_redirect) OVERRIDE { 124 bool* defer_redirect) OVERRIDE {
124 // Defer the redirect either way. 125 // Defer the redirect either way.
125 *defer_redirect = true; 126 *defer_redirect = true;
126 127
127 // Find out what the throttle would have done. 128 // Find out what the throttle would have done.
128 throttle_->WillRedirectRequest(new_url, &was_deferred_); 129 throttle_->WillRedirectRequest(redirect_info.new_url, &was_deferred_);
129 run_loop_->Quit(); 130 run_loop_->Quit();
130 } 131 }
131 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { } 132 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { }
132 virtual void OnReadCompleted(net::URLRequest* request, 133 virtual void OnReadCompleted(net::URLRequest* request,
133 int bytes_read) OVERRIDE { 134 int bytes_read) OVERRIDE {
134 } 135 }
135 136
136 // content::ResourceController implementation: 137 // content::ResourceController implementation:
137 virtual void Cancel() OVERRIDE { 138 virtual void Cancel() OVERRIDE {
138 EXPECT_FALSE(cancel_called_); 139 EXPECT_FALSE(cancel_called_);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // We should have cancelled the prerender. 335 // We should have cancelled the prerender.
335 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, 336 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT,
336 test_contents()->final_status()); 337 test_contents()->final_status());
337 338
338 // Cleanup work so the prerender is gone. 339 // Cleanup work so the prerender is gone.
339 test_contents()->Cancel(); 340 test_contents()->Cancel();
340 RunEvents(); 341 RunEvents();
341 } 342 }
342 343
343 } // namespace prerender 344 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698