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

Side by Side Diff: content/common/resource_dispatcher_unittest.cc

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed some minor issues Created 8 years, 5 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/process.h" 10 #include "base/process.h"
11 #include "base/process_util.h" 11 #include "base/process_util.h"
12 #include "content/common/request_extra_data.h" 12 #include "content/common/request_extra_data.h"
13 #include "content/common/resource_dispatcher.h" 13 #include "content/common/resource_dispatcher.h"
14 #include "content/common/resource_messages.h" 14 #include "content/common/resource_messages.h"
15 #include "content/public/common/resource_response.h" 15 #include "content/public/common/resource_response.h"
16 #include "net/base/net_errors.h"
16 #include "net/base/upload_data.h" 17 #include "net/base/upload_data.h"
17 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/appcache/appcache_interfaces.h" 20 #include "webkit/appcache/appcache_interfaces.h"
20 21
21 using webkit_glue::ResourceLoaderBridge; 22 using webkit_glue::ResourceLoaderBridge;
22 using webkit_glue::ResourceResponseInfo; 23 using webkit_glue::ResourceResponseInfo;
23 24
24 static const char test_page_url[] = "http://www.google.com/"; 25 static const char test_page_url[] = "http://www.google.com/";
25 static const char test_page_headers[] = 26 static const char test_page_headers[] =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 59 }
59 60
60 virtual void OnReceivedData(const char* data, 61 virtual void OnReceivedData(const char* data,
61 int data_length, 62 int data_length,
62 int encoded_data_length) { 63 int encoded_data_length) {
63 EXPECT_FALSE(complete_); 64 EXPECT_FALSE(complete_);
64 data_.append(data, data_length); 65 data_.append(data, data_length);
65 total_encoded_data_length_ += encoded_data_length; 66 total_encoded_data_length_ += encoded_data_length;
66 } 67 }
67 68
68 virtual void OnCompletedRequest(const net::URLRequestStatus& status, 69 virtual void OnCompletedRequest(int error_code,
69 const std::string& security_info, 70 const std::string& security_info,
70 const base::TimeTicks& completion_time) { 71 const base::TimeTicks& completion_time) {
71 EXPECT_FALSE(complete_); 72 EXPECT_FALSE(complete_);
72 complete_ = true; 73 complete_ = true;
73 } 74 }
74 75
75 bool complete() const { 76 bool complete() const {
76 return complete_; 77 return complete_;
77 } 78 }
78 const std::string& data() const { 79 const std::string& data() const {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 237
237 virtual bool Send(IPC::Message* msg) { 238 virtual bool Send(IPC::Message* msg) {
238 delete msg; 239 delete msg;
239 return true; 240 return true;
240 } 241 }
241 242
242 void InitMessages() { 243 void InitMessages() {
243 set_defer_loading(true); 244 set_defer_loading(true);
244 245
245 content::ResourceResponseHead response_head; 246 content::ResourceResponseHead response_head;
246 response_head.status.set_status(net::URLRequestStatus::SUCCESS); 247 response_head.error_code = net::OK;
247 248
248 IPC::Message* response_message = 249 IPC::Message* response_message =
249 new ResourceMsg_ReceivedResponse(0, 0, response_head); 250 new ResourceMsg_ReceivedResponse(0, 0, response_head);
250 251
251 dispatcher_->OnMessageReceived(*response_message); 252 dispatcher_->OnMessageReceived(*response_message);
252 253
253 delete response_message; 254 delete response_message;
254 255
255 // Duplicate the shared memory handle so both the test and the callee can 256 // Duplicate the shared memory handle so both the test and the callee can
256 // close their copy. 257 // close their copy.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 virtual void OnDownloadedData(int len) { 290 virtual void OnDownloadedData(int len) {
290 } 291 }
291 292
292 virtual void OnReceivedData(const char* data, 293 virtual void OnReceivedData(const char* data,
293 int data_length, 294 int data_length,
294 int encoded_data_length) { 295 int encoded_data_length) {
295 EXPECT_EQ(defer_loading_, false); 296 EXPECT_EQ(defer_loading_, false);
296 set_defer_loading(false); 297 set_defer_loading(false);
297 } 298 }
298 299
299 virtual void OnCompletedRequest(const net::URLRequestStatus& status, 300 virtual void OnCompletedRequest(int error_code,
300 const std::string& security_info, 301 const std::string& security_info,
301 const base::TimeTicks& completion_time) { 302 const base::TimeTicks& completion_time) {
302 } 303 }
303 304
304 protected: 305 protected:
305 virtual void SetUp() { 306 virtual void SetUp() {
306 ResourceDispatcherTest::SetUp(); 307 ResourceDispatcherTest::SetUp();
307 shared_handle_.Delete(kShmemSegmentName); 308 shared_handle_.Delete(kShmemSegmentName);
308 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100)); 309 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100));
309 } 310 }
(...skipping 23 matching lines...) Expand all
333 334
334 ResourceLoaderBridge* bridge = CreateBridge(); 335 ResourceLoaderBridge* bridge = CreateBridge();
335 336
336 bridge->Start(this); 337 bridge->Start(this);
337 InitMessages(); 338 InitMessages();
338 339
339 // Dispatch deferred messages. 340 // Dispatch deferred messages.
340 message_loop.RunAllPending(); 341 message_loop.RunAllPending();
341 delete bridge; 342 delete bridge;
342 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698