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

Side by Side Diff: chrome/browser/page_cycler/page_cycler.cc

Issue 10551002: TabContentsWrapper -> TabContents, part 56. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Not killing GetSelectedWebContents yet Created 8 years, 6 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 "chrome/browser/page_cycler/page_cycler.h" 5 #include "chrome/browser/page_cycler/page_cycler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
24 24
25 using content::NavigationController; 25 using content::NavigationController;
26 using content::OpenURLParams; 26 using content::OpenURLParams;
27 using content::Referrer; 27 using content::Referrer;
28 using content::WebContents; 28 using content::WebContents;
29 29
30 PageCycler::PageCycler(Browser* browser, 30 PageCycler::PageCycler(Browser* browser,
31 const FilePath& urls_file) 31 const FilePath& urls_file)
32 : content::WebContentsObserver(browser->GetSelectedWebContents()), 32 : content::WebContentsObserver(browser->GetActiveWebContents()),
33 browser_(browser), 33 browser_(browser),
34 urls_file_(urls_file), 34 urls_file_(urls_file),
35 url_index_(0), 35 url_index_(0),
36 total_iterations_(0), 36 total_iterations_(0),
37 current_iteration_(0), 37 current_iteration_(0),
38 aborted_(false) { 38 aborted_(false) {
39 BrowserList::AddObserver(this); 39 BrowserList::AddObserver(this);
40 AddRef(); // Balanced in Finish()/Abort() (only one should be called). 40 AddRef(); // Balanced in Finish()/Abort() (only one should be called).
41 } 41 }
42 42
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void PageCycler::BeginCycle() { 127 void PageCycler::BeginCycle() {
128 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 128 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
129 129
130 CHECK(browser_); 130 CHECK(browser_);
131 // Upon launch, Chrome will automatically load the newtab page. This can 131 // Upon launch, Chrome will automatically load the newtab page. This can
132 // result in the browser being in a state of loading when PageCycler is ready 132 // result in the browser being in a state of loading when PageCycler is ready
133 // to start. Instead of interrupting the load, we wait for it to finish, and 133 // to start. Instead of interrupting the load, we wait for it to finish, and
134 // will call LoadNextURL() from DidFinishLoad() or DidFailProvisionalLoad(). 134 // will call LoadNextURL() from DidFinishLoad() or DidFailProvisionalLoad().
135 if (browser_->GetSelectedWebContents()->IsLoading()) 135 if (browser_->GetActiveWebContents()->IsLoading())
136 return; 136 return;
137 LoadNextURL(); 137 LoadNextURL();
138 } 138 }
139 139
140 void PageCycler::LoadNextURL() { 140 void PageCycler::LoadNextURL() {
141 CHECK(browser_); 141 CHECK(browser_);
142 if (url_index_ >= urls_.size()) { 142 if (url_index_ >= urls_.size()) {
143 if (current_iteration_ < total_iterations_ - 1) { 143 if (current_iteration_ < total_iterations_ - 1) {
144 ++current_iteration_; 144 ++current_iteration_;
145 url_index_ = 0; 145 url_index_ = 0;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 aborted_ = true; 254 aborted_ = true;
255 error_.append(ASCIIToUTF16( 255 error_.append(ASCIIToUTF16(
256 "Browser was closed before the run was completed.")); 256 "Browser was closed before the run was completed."));
257 DLOG(WARNING) << 257 DLOG(WARNING) <<
258 "Page Cycler: browser was closed before the run was completed."; 258 "Page Cycler: browser was closed before the run was completed.";
259 content::BrowserThread::PostBlockingPoolTask( 259 content::BrowserThread::PostBlockingPoolTask(
260 FROM_HERE, 260 FROM_HERE,
261 base::Bind(&PageCycler::PrepareResultsOnBackgroundThread, this)); 261 base::Bind(&PageCycler::PrepareResultsOnBackgroundThread, this));
262 } 262 }
263 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/net/load_timing_observer_browsertest.cc ('k') | chrome/browser/page_cycler/page_cycler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698