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

Unified Diff: content/worker/websharedworker_stub.cc

Issue 22314003: NavigationController prototype Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NavController prototype - chrome side Created 7 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
« no previous file with comments | « content/worker/websharedworker_stub.h ('k') | content/worker/worker_webkitplatformsupport_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/worker/websharedworker_stub.cc
diff --git a/content/worker/websharedworker_stub.cc b/content/worker/websharedworker_stub.cc
index 745b63c1956abf61d13cd564e4ef1667c38fa23b..22f1343ec30a8fda87cc047039f240e565871bb8 100644
--- a/content/worker/websharedworker_stub.cc
+++ b/content/worker/websharedworker_stub.cc
@@ -5,6 +5,7 @@
#include "content/worker/websharedworker_stub.h"
#include "base/compiler_specific.h"
+#include "base/strings/utf_string_conversions.h"
#include "content/child/child_process.h"
#include "content/child/child_thread.h"
#include "content/child/fileapi/file_system_dispatcher.h"
@@ -13,8 +14,12 @@
#include "content/worker/shared_worker_devtools_agent.h"
#include "content/worker/worker_thread.h"
#include "third_party/WebKit/public/web/WebSharedWorker.h"
+#include "third_party/WebKit/public/platform/WebCString.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
+#include "content/common/appcache_messages.h"
+
+using WebKit::WebController;
namespace content {
@@ -26,7 +31,8 @@ WebSharedWorkerStub::WebSharedWorkerStub(
appcache_init_info_(appcache_init_info),
client_(route_id, this),
name_(name),
- started_(false) {
+ started_(false),
+ is_embedded_worker_(false) {
WorkerThread* worker_thread = WorkerThread::current();
DCHECK(worker_thread);
@@ -66,9 +72,12 @@ bool WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerStub, message)
IPC_MESSAGE_HANDLER(WorkerMsg_StartWorkerContext, OnStartWorkerContext)
+ IPC_MESSAGE_HANDLER(WorkerMsg_StartEmbeddedWorkerContext,
+ OnStartEmbeddedWorkerContext);
IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
OnTerminateWorkerContext)
IPC_MESSAGE_HANDLER(WorkerMsg_Connect, OnConnect)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_FetchEvent, OnFetchEvent)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -88,11 +97,12 @@ void WebSharedWorkerStub::OnStartWorkerContext(
WebKit::WebContentSecurityPolicyType policy_type) {
// Ignore multiple attempts to start this worker (can happen if two pages
// try to start it simultaneously).
+ DCHECK(!is_embedded_worker_);
if (started_)
return;
impl_->startWorkerContext(url, name_, user_agent, source_code,
- content_security_policy, policy_type, 0);
+ content_security_policy, policy_type, 0, false);
started_ = true;
url_ = url;
@@ -105,6 +115,25 @@ void WebSharedWorkerStub::OnStartWorkerContext(
pending_connects_.clear();
}
+void WebSharedWorkerStub::OnStartEmbeddedWorkerContext(
+ const GURL& url, const std::string& raw_source_code) {
+ DCHECK(!started_);
+
+ is_embedded_worker_ = true;
+
+ // TODO: plug some values in here.
+ string16 user_agent;
+ string16 content_security_policy;
+ WebKit::WebContentSecurityPolicyType policy_type = WebKit::WebContentSecurityPolicyType(0);
+ WebKit::WebString source_code =
+ WebKit::WebString::fromUTF8(raw_source_code.data(),
+ raw_source_code.length());
+ impl_->startWorkerContext(url, name_, user_agent, source_code,
+ content_security_policy, policy_type, 0, true);
+ started_ = true;
+ url_ = url;
+}
+
void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) {
if (started_) {
WebKit::WebMessagePortChannel* channel =
@@ -122,6 +151,40 @@ void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) {
}
}
+void WebSharedWorkerStub::OnFetchEvent(
+ int request_id,
+ const appcache::AppCacheExecutableHandler::Request& request) {
+ CHECK(started_);
+ // TODO: there are more data members here then we really support atm
+ // and some of them look questionable as to whether they're really needed.
+ // We should prune this to be more minimalistic and reflective of what is
+ // actuall supported atm.
+ //
+ // ANOTHER TODO: this struct is not composed of thread safe string types
+ // yet it's being posted across threads :( We need to avoid using
+ // WebKit defined classes and interfaces for marshalling data around.
+ // fyi: WebString and WebCore::String are landmines.
+ // The response plumbing has the same problem with WebControllerResponse
+ // structs.
+ WebController::Request* webRequest = new WebController::Request();
+ webRequest->url = request.url;
+ webRequest->method = ASCIIToUTF16(request.method);
+ webRequest->referrer = ASCIIToUTF16(request.referrer); // ??? this is a url
+ for (std::map<std::string, std::string>::const_iterator iter = request.headers.begin();
+ iter != request.headers.end();
+ ++iter) {
+ webRequest->headers.push_back(std::make_pair(
+ WebKit::WebString(UTF8ToUTF16(iter->first)),
+ WebKit::WebString(UTF8ToUTF16(iter->second))));
+ }
+
+ impl_->dispatchFetchEvent(request_id, webRequest);
+}
+
+void WebSharedWorkerStub::OnInstallEvent(int host_id) {
+ CHECK(false);
+}
+
void WebSharedWorkerStub::OnTerminateWorkerContext() {
impl_->terminateWorkerContext();
« no previous file with comments | « content/worker/websharedworker_stub.h ('k') | content/worker/worker_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698