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

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

Issue 283623002: Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for Web… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 virtual bool Send(IPC::Message* msg) OVERRIDE { 105 virtual bool Send(IPC::Message* msg) OVERRIDE {
106 message_queue_.push_back(IPC::Message(*msg)); 106 message_queue_.push_back(IPC::Message(*msg));
107 delete msg; 107 delete msg;
108 return true; 108 return true;
109 } 109 }
110 110
111 // Emulates the browser process and processes the pending IPC messages, 111 // Emulates the browser process and processes the pending IPC messages,
112 // returning the hardcoded file contents. 112 // returning the hardcoded file contents.
113 void ProcessMessages() { 113 void ProcessMessages() {
114 while (!message_queue_.empty()) { 114 while (!message_queue_.empty()) {
115 int request_id; 115 ResourceHostMsg_RequestResource::Param params;
116 ResourceHostMsg_Request request;
117 ASSERT_TRUE(ResourceHostMsg_RequestResource::Read( 116 ASSERT_TRUE(ResourceHostMsg_RequestResource::Read(
118 &message_queue_[0], &request_id, &request)); 117 &message_queue_[0], &params));
118 int request_id = params.b;
119 ResourceHostMsg_Request request = params.c;
119 120
120 // check values 121 // check values
121 EXPECT_EQ(test_page_url, request.url.spec()); 122 EXPECT_EQ(test_page_url, request.url.spec());
122 123
123 // received response message 124 // received response message
124 ResourceResponseHead response; 125 ResourceResponseHead response;
125 std::string raw_headers(test_page_headers); 126 std::string raw_headers(test_page_headers);
126 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); 127 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
127 response.headers = new net::HttpResponseHeaders(raw_headers); 128 response.headers = new net::HttpResponseHeaders(raw_headers);
128 response.mime_type = test_page_mime_type; 129 response.mime_type = test_page_mime_type;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 response_head.error_code = net::OK; 434 response_head.error_code = net::OK;
434 435
435 PerformTest(response_head); 436 PerformTest(response_head);
436 437
437 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); 438 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start);
438 EXPECT_EQ(base::TimeTicks(), 439 EXPECT_EQ(base::TimeTicks(),
439 response_info().load_timing.connect_timing.dns_start); 440 response_info().load_timing.connect_timing.dns_start);
440 } 441 }
441 442
442 } // namespace content 443 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698