summaryrefslogtreecommitdiffstats
path: root/chrome/common/resource_dispatcher_unittest.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 21:42:52 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 21:42:52 +0000
commiteb9989097eb86b7cc6e535a1d69112b3a38a02c0 (patch)
treec9918e47c10ae09ca9d0f82928075624b10c9c2a /chrome/common/resource_dispatcher_unittest.cc
parent3e896efc285b9656fab36fa855d796b16634bd94 (diff)
downloadchromium_src-eb9989097eb86b7cc6e535a1d69112b3a38a02c0.zip
chromium_src-eb9989097eb86b7cc6e535a1d69112b3a38a02c0.tar.gz
chromium_src-eb9989097eb86b7cc6e535a1d69112b3a38a02c0.tar.bz2
Switch to using one ResourceDispatcher per render process, and move it to ChildThread so that the same code is used by the plugin process (and soon, workers).
Review URL: http://codereview.chromium.org/42108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/resource_dispatcher_unittest.cc')
-rw-r--r--chrome/common/resource_dispatcher_unittest.cc29
1 files changed, 13 insertions, 16 deletions
diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc
index a3eea69..a53f0c3 100644
--- a/chrome/common/resource_dispatcher_unittest.cc
+++ b/chrome/common/resource_dispatcher_unittest.cc
@@ -6,7 +6,6 @@
#include <vector>
#include "base/process.h"
-#include "base/ref_counted.h"
#include "chrome/common/filter_policy.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/resource_dispatcher.h"
@@ -86,13 +85,10 @@ class ResourceDispatcherTest : public testing::Test,
// returning the hardcoded file contents.
void ProcessMessages() {
while (!message_queue_.empty()) {
- void* iter = NULL;
-
int request_id;
- ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request_id));
-
ViewHostMsg_Resource_Request request;
- ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request));
+ ASSERT_TRUE(ViewHostMsg_RequestResource::Read(
+ &message_queue_[0], &request_id, &request));
// check values
EXPECT_EQ(test_page_url, request.url.spec());
@@ -117,15 +113,15 @@ class ResourceDispatcherTest : public testing::Test,
base::SharedMemoryHandle dup_handle;
EXPECT_TRUE(shared_mem.GiveToProcess(
base::Process::Current().handle(), &dup_handle));
- dispatcher_->OnReceivedData(request_id, dup_handle,
- test_page_contents_len);
+ dispatcher_->OnReceivedData(
+ message_queue_[0], request_id, dup_handle, test_page_contents_len);
message_queue_.erase(message_queue_.begin());
// read the ack message.
- iter = NULL;
int request_ack = -1;
- ASSERT_TRUE(IPC::ReadParam(&message_queue_[0], &iter, &request_ack));
+ ASSERT_TRUE(ViewHostMsg_DataReceived_ACK::Read(
+ &message_queue_[0], &request_ack));
ASSERT_EQ(request_ack, request_id);
@@ -135,23 +131,23 @@ class ResourceDispatcherTest : public testing::Test,
protected:
static ResourceDispatcher* GetResourceDispatcher(WebFrame* unused) {
- return dispatcher_;
+ return dispatcher_.get();
}
// testing::Test
virtual void SetUp() {
- dispatcher_ = new ResourceDispatcher(this);
+ dispatcher_.reset(new ResourceDispatcher(this));
}
virtual void TearDown() {
- dispatcher_ = NULL;
+ dispatcher_.reset();
}
std::vector<IPC::Message> message_queue_;
- static scoped_refptr<ResourceDispatcher> dispatcher_;
+ static scoped_ptr<ResourceDispatcher> dispatcher_;
};
/*static*/
-scoped_refptr<ResourceDispatcher> ResourceDispatcherTest::dispatcher_;
+scoped_ptr<ResourceDispatcher> ResourceDispatcherTest::dispatcher_;
// Does a simple request and tests that the correct data is received.
TEST_F(ResourceDispatcherTest, RoundTrip) {
@@ -159,7 +155,8 @@ TEST_F(ResourceDispatcherTest, RoundTrip) {
ResourceLoaderBridge* bridge =
dispatcher_->CreateBridge("GET", GURL(test_page_url), GURL(test_page_url),
GURL(), std::string(), 0, 0,
- ResourceType::SUB_RESOURCE, false, 0);
+ ResourceType::SUB_RESOURCE, false, 0,
+ MSG_ROUTING_CONTROL);
bridge->Start(&callback);