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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 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 <iostream> 5 #include <iostream>
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // TODO(shishir): Enable the prefetching mode in the tests. 149 // TODO(shishir): Enable the prefetching mode in the tests.
150 config.mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; 150 config.mode |= ResourcePrefetchPredictorConfig::URL_LEARNING;
151 config.mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; 151 config.mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING;
152 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); 152 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get()));
153 predictor_->set_mock_tables(mock_tables_); 153 predictor_->set_mock_tables(mock_tables_);
154 } 154 }
155 155
156 void InitializeSampleData(); 156 void InitializeSampleData();
157 157
158 MessageLoop loop_; 158 base::MessageLoop loop_;
159 content::TestBrowserThread ui_thread_; 159 content::TestBrowserThread ui_thread_;
160 content::TestBrowserThread db_thread_; 160 content::TestBrowserThread db_thread_;
161 scoped_ptr<TestingProfile> profile_; 161 scoped_ptr<TestingProfile> profile_;
162 162
163 scoped_ptr<ResourcePrefetchPredictor> predictor_; 163 scoped_ptr<ResourcePrefetchPredictor> predictor_;
164 scoped_refptr<StrictMock<MockResourcePrefetchPredictorTables> > mock_tables_; 164 scoped_refptr<StrictMock<MockResourcePrefetchPredictorTables> > mock_tables_;
165 165
166 PrefetchDataMap test_url_data_; 166 PrefetchDataMap test_url_data_;
167 PrefetchDataMap test_host_data_; 167 PrefetchDataMap test_host_data_;
168 PrefetchData empty_url_data_; 168 PrefetchData empty_url_data_;
169 PrefetchData empty_host_data_; 169 PrefetchData empty_host_data_;
170 }; 170 };
171 171
172 ResourcePrefetchPredictorTest::ResourcePrefetchPredictorTest() 172 ResourcePrefetchPredictorTest::ResourcePrefetchPredictorTest()
173 : loop_(MessageLoop::TYPE_DEFAULT), 173 : loop_(base::MessageLoop::TYPE_DEFAULT),
174 ui_thread_(content::BrowserThread::UI, &loop_), 174 ui_thread_(content::BrowserThread::UI, &loop_),
175 db_thread_(content::BrowserThread::DB, &loop_), 175 db_thread_(content::BrowserThread::DB, &loop_),
176 profile_(new TestingProfile()), 176 profile_(new TestingProfile()),
177 predictor_(NULL), 177 predictor_(NULL),
178 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()), 178 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()),
179 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()), 179 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()),
180 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {} 180 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {}
181 181
182 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { 182 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() {
183 profile_.reset(NULL); 183 profile_.reset(NULL);
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(0))); 918 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(0)));
919 EXPECT_TRUE(URLRequestSummaryAreEqual( 919 EXPECT_TRUE(URLRequestSummaryAreEqual(
920 resource2, 920 resource2,
921 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(1))); 921 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(1)));
922 EXPECT_TRUE(URLRequestSummaryAreEqual( 922 EXPECT_TRUE(URLRequestSummaryAreEqual(
923 resource3, 923 resource3,
924 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(2))); 924 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(2)));
925 } 925 }
926 926
927 } // namespace predictors 927 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698