OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH | 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH |
6 // results | 6 // results |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 fetcher_->Start(); | 278 fetcher_->Start(); |
279 if (!url_fetch_complete_) { | 279 if (!url_fetch_complete_) { |
280 waiting_ = true; | 280 waiting_ = true; |
281 content::RunMessageLoop(); | 281 content::RunMessageLoop(); |
282 waiting_ = false; | 282 waiting_ = false; |
283 } | 283 } |
284 CHECK(url_fetch_complete_); | 284 CHECK(url_fetch_complete_); |
285 } | 285 } |
286 | 286 |
287 void FetchUrl(GURL url) { | 287 void FetchUrl(GURL url) { |
288 FetchUrlDetailed(url, url_request_context_getter_); | 288 FetchUrlDetailed(url, url_request_context_getter_.get()); |
289 } | 289 } |
290 | 290 |
291 const net::URLRequestStatus& FetcherStatus() const { | 291 const net::URLRequestStatus& FetcherStatus() const { |
292 return fetcher_->GetStatus(); | 292 return fetcher_->GetStatus(); |
293 } | 293 } |
294 | 294 |
295 int FetcherResponseCode() const { | 295 int FetcherResponseCode() const { |
296 return (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS ? | 296 return (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS ? |
297 fetcher_->GetResponseCode() : 0); | 297 fetcher_->GetResponseCode() : 0); |
298 } | 298 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 *sdch_encoding_used = | 334 *sdch_encoding_used = |
335 FetcherResponseHeaders()->HasHeaderValue("Content-Encoding", "sdch"); | 335 FetcherResponseHeaders()->HasHeaderValue("Content-Encoding", "sdch"); |
336 | 336 |
337 if (FetcherResponseContents() != kSampleData) | 337 if (FetcherResponseContents() != kSampleData) |
338 return false; | 338 return false; |
339 | 339 |
340 return true; | 340 return true; |
341 } | 341 } |
342 | 342 |
343 bool GetData(bool* sdch_encoding_used) { | 343 bool GetData(bool* sdch_encoding_used) { |
344 return GetDataDetailed( | 344 return GetDataDetailed(url_request_context_getter_.get(), |
345 url_request_context_getter_, sdch_encoding_used); | 345 sdch_encoding_used); |
346 } | 346 } |
347 | 347 |
348 // Client information and control. | 348 // Client information and control. |
349 | 349 |
350 int GetNumberOfDictionaryFetches(Profile* profile) { | 350 int GetNumberOfDictionaryFetches(Profile* profile) { |
351 int fetches = -1; | 351 int fetches = -1; |
352 base::RunLoop run_loop; | 352 base::RunLoop run_loop; |
353 content::BrowserThread::PostTaskAndReply( | 353 content::BrowserThread::PostTaskAndReply( |
354 content::BrowserThread::IO, FROM_HERE, | 354 content::BrowserThread::IO, FROM_HERE, |
355 base::Bind(&SdchBrowserTest::GetNumberOfDictionaryFetchesOnIOThread, | 355 base::Bind(&SdchBrowserTest::GetNumberOfDictionaryFetchesOnIOThread, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 Browser* incognito_browser = CreateIncognitoBrowser(); | 608 Browser* incognito_browser = CreateIncognitoBrowser(); |
609 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser)); | 609 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser)); |
610 | 610 |
611 // Data fetches on main browser should not be SDCH encoded. | 611 // Data fetches on main browser should not be SDCH encoded. |
612 bool sdch_encoding_used = true; | 612 bool sdch_encoding_used = true; |
613 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 613 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
614 EXPECT_FALSE(sdch_encoding_used); | 614 EXPECT_FALSE(sdch_encoding_used); |
615 } | 615 } |
616 | 616 |
617 } // namespace | 617 } // namespace |
OLD | NEW |