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

Unified Diff: chrome_frame/test/net/test_automation_resource_message_filter.cc

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome_frame/test/net/test_automation_resource_message_filter.cc
===================================================================
--- chrome_frame/test/net/test_automation_resource_message_filter.cc (revision 0)
+++ chrome_frame/test/net/test_automation_resource_message_filter.cc (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome_frame/test/net/test_automation_resource_message_filter.h"
+
+TestAutomationResourceMessageFilter::TestAutomationResourceMessageFilter(
+ AutomationProvider* automation) : automation_(automation) {
+}
+
+bool TestAutomationResourceMessageFilter::Send(IPC::Message* message) {
+ return automation_->Send(message);
+}
+
+// static
+void TestAutomationResourceMessageFilter::OnRequestMessage(
+ URLRequestAutomationJob* job, IPC::Message* msg) {
+ job->OnMessage(*msg);
+ delete msg;
+}
+
+bool TestAutomationResourceMessageFilter::OnMessageReceived(
+ const IPC::Message& message) {
+ // See if we want to process this message... call the base class
+ // for filter messages, send the message to the correct thread
+ // for URL requests.
+ bool handled = false;
+ int request_id = URLRequestAutomationJob::MayFilterMessage(message);
+ if (request_id) {
+ RequestMap::iterator it = requests_.find(request_id);
+ if (it != requests_.end()) {
+ handled = true;
+ IPC::Message* msg = new IPC::Message(message);
+ RequestJob& job = it->second;
+ job.loop_->PostTask(FROM_HERE, NewRunnableFunction(OnRequestMessage,
+ job.job_, msg));
+ }
+ } else {
+ handled = AutomationResourceMessageFilter::OnMessageReceived(message);
+ }
+ return handled;
+}
+
+// Add request to the list of outstanding requests.
+bool TestAutomationResourceMessageFilter::RegisterRequest(
+ URLRequestAutomationJob* job) {
+ // Store the request in an internal map like the parent class
+ // does, but also store the current loop pointer so we can send
+ // request messages to that loop.
+ DCHECK(requests_.end() == requests_.find(job->id()));
+ RequestJob request_job = { MessageLoop::current(), job };
+ requests_[job->id()] = request_job;
+ return true;
+}
+
+// Remove request from the list of outstanding requests.
+void TestAutomationResourceMessageFilter::UnRegisterRequest(
+ URLRequestAutomationJob* job) {
+ requests_.erase(job->id());
+}
« no previous file with comments | « chrome_frame/test/net/test_automation_resource_message_filter.h ('k') | chrome_frame/test/perf/chrome_frame_perftest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698