| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 "<html><head><title>Google</title></head><body><h1>Google</h1></body></html>"; | 25 "<html><head><title>Google</title></head><body><h1>Google</h1></body></html>"; |
| 26 static const uint32 test_page_contents_len = arraysize(test_page_contents) - 1; | 26 static const uint32 test_page_contents_len = arraysize(test_page_contents) - 1; |
| 27 | 27 |
| 28 // Listens for request response data and stores it so that it can be compared | 28 // Listens for request response data and stores it so that it can be compared |
| 29 // to the reference data. | 29 // to the reference data. |
| 30 class TestRequestCallback : public ResourceLoaderBridge::Peer { | 30 class TestRequestCallback : public ResourceLoaderBridge::Peer { |
| 31 public: | 31 public: |
| 32 TestRequestCallback() : complete_(false) { | 32 TestRequestCallback() : complete_(false) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void OnUploadProgress(uint64 position, uint64 size) { |
| 36 } |
| 37 |
| 35 virtual bool OnReceivedRedirect( | 38 virtual bool OnReceivedRedirect( |
| 36 const GURL& new_url, | 39 const GURL& new_url, |
| 37 const ResourceLoaderBridge::ResponseInfo& info, | 40 const ResourceLoaderBridge::ResponseInfo& info, |
| 38 bool* has_new_first_party_for_cookies, | 41 bool* has_new_first_party_for_cookies, |
| 39 GURL* new_first_party_for_cookies) { | 42 GURL* new_first_party_for_cookies) { |
| 40 *has_new_first_party_for_cookies = false; | 43 *has_new_first_party_for_cookies = false; |
| 41 return true; | 44 return true; |
| 42 } | 45 } |
| 43 | 46 |
| 44 virtual void OnReceivedResponse( | 47 virtual void OnReceivedResponse( |
| 45 const ResourceLoaderBridge::ResponseInfo& info, | 48 const ResourceLoaderBridge::ResponseInfo& info, |
| 46 bool content_filtered) { | 49 bool content_filtered) { |
| 47 } | 50 } |
| 48 | 51 |
| 52 virtual void OnDownloadedData(int len) { |
| 53 } |
| 54 |
| 49 virtual void OnReceivedData(const char* data, int len) { | 55 virtual void OnReceivedData(const char* data, int len) { |
| 50 EXPECT_FALSE(complete_); | 56 EXPECT_FALSE(complete_); |
| 51 data_.append(data, len); | 57 data_.append(data, len); |
| 52 } | 58 } |
| 53 | 59 |
| 54 virtual void OnUploadProgress(uint64 position, uint64 size) { | |
| 55 } | |
| 56 | |
| 57 virtual void OnCompletedRequest(const URLRequestStatus& status, | 60 virtual void OnCompletedRequest(const URLRequestStatus& status, |
| 58 const std::string& security_info) { | 61 const std::string& security_info) { |
| 59 EXPECT_FALSE(complete_); | 62 EXPECT_FALSE(complete_); |
| 60 complete_ = true; | 63 complete_ = true; |
| 61 } | 64 } |
| 62 | 65 |
| 63 virtual GURL GetURLForDebugging() const { | 66 virtual GURL GetURLForDebugging() const { |
| 64 return GURL(); | 67 return GURL(); |
| 65 } | 68 } |
| 66 | 69 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 new ViewMsg_Resource_DataReceived(0, 0, duplicated_handle, 100); | 248 new ViewMsg_Resource_DataReceived(0, 0, duplicated_handle, 100); |
| 246 | 249 |
| 247 dispatcher_->OnMessageReceived(*response_message); | 250 dispatcher_->OnMessageReceived(*response_message); |
| 248 | 251 |
| 249 delete response_message; | 252 delete response_message; |
| 250 | 253 |
| 251 set_defer_loading(false); | 254 set_defer_loading(false); |
| 252 } | 255 } |
| 253 | 256 |
| 254 // ResourceLoaderBridge::Peer methods. | 257 // ResourceLoaderBridge::Peer methods. |
| 255 virtual void OnReceivedResponse( | 258 virtual void OnUploadProgress(uint64 position, uint64 size) { |
| 256 const ResourceLoaderBridge::ResponseInfo& info, | |
| 257 bool content_filtered) { | |
| 258 EXPECT_EQ(defer_loading_, false); | |
| 259 set_defer_loading(true); | |
| 260 } | 259 } |
| 261 | 260 |
| 262 virtual bool OnReceivedRedirect( | 261 virtual bool OnReceivedRedirect( |
| 263 const GURL& new_url, | 262 const GURL& new_url, |
| 264 const ResourceLoaderBridge::ResponseInfo& info, | 263 const ResourceLoaderBridge::ResponseInfo& info, |
| 265 bool* has_new_first_party_for_cookies, | 264 bool* has_new_first_party_for_cookies, |
| 266 GURL* new_first_party_for_cookies) { | 265 GURL* new_first_party_for_cookies) { |
| 267 *has_new_first_party_for_cookies = false; | 266 *has_new_first_party_for_cookies = false; |
| 268 return true; | 267 return true; |
| 269 } | 268 } |
| 270 | 269 |
| 270 virtual void OnReceivedResponse( |
| 271 const ResourceLoaderBridge::ResponseInfo& info, |
| 272 bool content_filtered) { |
| 273 EXPECT_EQ(defer_loading_, false); |
| 274 set_defer_loading(true); |
| 275 } |
| 276 |
| 277 virtual void OnDownloadedData(int len) { |
| 278 } |
| 279 |
| 271 virtual void OnReceivedData(const char* data, int len) { | 280 virtual void OnReceivedData(const char* data, int len) { |
| 272 EXPECT_EQ(defer_loading_, false); | 281 EXPECT_EQ(defer_loading_, false); |
| 273 set_defer_loading(false); | 282 set_defer_loading(false); |
| 274 } | 283 } |
| 275 | 284 |
| 276 virtual void OnUploadProgress(uint64 position, uint64 size) { | |
| 277 } | |
| 278 | |
| 279 virtual void OnCompletedRequest(const URLRequestStatus& status, | 285 virtual void OnCompletedRequest(const URLRequestStatus& status, |
| 280 const std::string& security_info) { | 286 const std::string& security_info) { |
| 281 } | 287 } |
| 282 | 288 |
| 283 virtual GURL GetURLForDebugging() const { | 289 virtual GURL GetURLForDebugging() const { |
| 284 return GURL(); | 290 return GURL(); |
| 285 } | 291 } |
| 286 | 292 |
| 287 protected: | 293 protected: |
| 288 virtual void SetUp() { | 294 virtual void SetUp() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 316 ResourceLoaderBridge* bridge = CreateBridge(); | 322 ResourceLoaderBridge* bridge = CreateBridge(); |
| 317 | 323 |
| 318 bridge->Start(this); | 324 bridge->Start(this); |
| 319 InitMessages(); | 325 InitMessages(); |
| 320 | 326 |
| 321 // Dispatch deferred messages. | 327 // Dispatch deferred messages. |
| 322 message_loop.RunAllPending(); | 328 message_loop.RunAllPending(); |
| 323 delete bridge; | 329 delete bridge; |
| 324 } | 330 } |
| 325 | 331 |
| OLD | NEW |