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

Side by Side Diff: content/renderer/resource_fetcher_browsertest.cc

Issue 117693002: Make RenderFrameHostManager swap RenderFrameHosts, not RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts Created 7 years 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
« no previous file with comments | « content/renderer/dom_serializer_browsertest.cc ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/renderer/resource_fetcher.h" 5 #include "content/public/renderer/resource_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/url_constants.h" 14 #include "content/public/common/url_constants.h"
15 #include "content/public/renderer/render_view.h" 15 #include "content/public/renderer/render_view.h"
16 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
17 #include "content/shell/browser/shell.h" 17 #include "content/shell/browser/shell.h"
18 #include "content/test/content_browser_test.h" 18 #include "content/test/content_browser_test.h"
19 #include "content/test/content_browser_test_utils.h" 19 #include "content/test/content_browser_test_utils.h"
20 #include "third_party/WebKit/public/platform/WebURLResponse.h" 20 #include "third_party/WebKit/public/platform/WebURLResponse.h"
21 #include "third_party/WebKit/public/web/WebFrame.h" 21 #include "third_party/WebKit/public/web/WebFrame.h"
22 #include "third_party/WebKit/public/web/WebView.h" 22 #include "third_party/WebKit/public/web/WebView.h"
23 23
24 using blink::WebFrame; 24 using blink::WebFrame;
25 using blink::WebURLRequest; 25 using blink::WebURLRequest;
26 using blink::WebURLResponse; 26 using blink::WebURLResponse;
27 27
28 namespace {
29
30 // The first RenderFrame is routing ID 1, and the first RenderView is 2.
31 const int kRenderViewRoutingId = 2;
32
33 }
34
28 namespace content { 35 namespace content {
29 36
30 static const int kMaxWaitTimeMs = 5000; 37 static const int kMaxWaitTimeMs = 5000;
31 38
32 class FetcherDelegate { 39 class FetcherDelegate {
33 public: 40 public:
34 FetcherDelegate() 41 FetcherDelegate()
35 : completed_(false), 42 : completed_(false),
36 timed_out_(false) { 43 timed_out_(false) {
37 // Start a repeating timer waiting for the download to complete. The 44 // Start a repeating timer waiting for the download to complete. The
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 command_line->AppendSwitch(switches::kSingleProcess); 135 command_line->AppendSwitch(switches::kSingleProcess);
129 #if defined(OS_WIN) && defined(USE_AURA) 136 #if defined(OS_WIN) && defined(USE_AURA)
130 // Don't want to try to create a GPU process. 137 // Don't want to try to create a GPU process.
131 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); 138 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
132 #endif 139 #endif
133 } 140 }
134 141
135 RenderView* GetRenderView() { 142 RenderView* GetRenderView() {
136 // We could have the test on the UI thread get the WebContent's routing ID, 143 // We could have the test on the UI thread get the WebContent's routing ID,
137 // but we know this will be the first RV so skip that and just hardcode it. 144 // but we know this will be the first RV so skip that and just hardcode it.
138 return RenderView::FromRoutingID(1); 145 return RenderView::FromRoutingID(kRenderViewRoutingId);
139 } 146 }
140 147
141 void ResourceFetcherDownloadOnRenderer(const GURL& url) { 148 void ResourceFetcherDownloadOnRenderer(const GURL& url) {
142 WebFrame* frame = GetRenderView()->GetWebView()->mainFrame(); 149 WebFrame* frame = GetRenderView()->GetWebView()->mainFrame();
143 150
144 scoped_ptr<FetcherDelegate> delegate(new FetcherDelegate); 151 scoped_ptr<FetcherDelegate> delegate(new FetcherDelegate);
145 scoped_ptr<ResourceFetcher> fetcher(ResourceFetcher::Create( 152 scoped_ptr<ResourceFetcher> fetcher(ResourceFetcher::Create(
146 url, frame, WebURLRequest::TargetIsMainFrame, delegate->NewCallback())); 153 url, frame, WebURLRequest::TargetIsMainFrame, delegate->NewCallback()));
147 154
148 delegate->WaitForResponse(); 155 delegate->WaitForResponse();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 ASSERT_TRUE(test_server()->Start()); 287 ASSERT_TRUE(test_server()->Start());
281 GURL url(test_server()->GetURL("slow?1")); 288 GURL url(test_server()->GetURL("slow?1"));
282 289
283 PostTaskToInProcessRendererAndWait( 290 PostTaskToInProcessRendererAndWait(
284 base::Bind( 291 base::Bind(
285 &ResourceFetcherTests::ResourceFetcherDeletedInCallbackOnRenderer, 292 &ResourceFetcherTests::ResourceFetcherDeletedInCallbackOnRenderer,
286 base::Unretained(this), url)); 293 base::Unretained(this), url));
287 } 294 }
288 295
289 } // namespace content 296 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_serializer_browsertest.cc ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698