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

Side by Side Diff: content/renderer/service_worker/embedded_worker_dispatcher.cc

Issue 186883002: Move user_agent code from webkit/ to content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/service_worker/embedded_worker_dispatcher.h" 5 #include "content/renderer/service_worker/embedded_worker_dispatcher.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/child/child_process.h" 10 #include "content/child/child_process.h"
11 #include "content/child/scoped_child_process_reference.h" 11 #include "content/child/scoped_child_process_reference.h"
12 #include "content/child/thread_safe_sender.h" 12 #include "content/child/thread_safe_sender.h"
13 #include "content/child/worker_task_runner.h" 13 #include "content/child/worker_task_runner.h"
14 #include "content/common/service_worker/embedded_worker_messages.h" 14 #include "content/common/service_worker/embedded_worker_messages.h"
15 #include "content/public/common/user_agent.h"
15 #include "content/renderer/render_thread_impl.h" 16 #include "content/renderer/render_thread_impl.h"
16 #include "content/renderer/service_worker/embedded_worker_context_client.h" 17 #include "content/renderer/service_worker/embedded_worker_context_client.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
19 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h" 20 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h"
20 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h" 21 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h"
21 #include "webkit/common/user_agent/user_agent.h"
22 22
23 namespace content { 23 namespace content {
24 24
25 // A thin wrapper of WebEmbeddedWorker which also adds and releases process 25 // A thin wrapper of WebEmbeddedWorker which also adds and releases process
26 // references automatically. 26 // references automatically.
27 class EmbeddedWorkerDispatcher::WorkerWrapper { 27 class EmbeddedWorkerDispatcher::WorkerWrapper {
28 public: 28 public:
29 explicit WorkerWrapper(blink::WebEmbeddedWorker* worker) : worker_(worker) {} 29 explicit WorkerWrapper(blink::WebEmbeddedWorker* worker) : worker_(worker) {}
30 ~WorkerWrapper() {} 30 ~WorkerWrapper() {}
31 31
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 scoped_ptr<WorkerWrapper> wrapper(new WorkerWrapper( 66 scoped_ptr<WorkerWrapper> wrapper(new WorkerWrapper(
67 blink::WebEmbeddedWorker::create( 67 blink::WebEmbeddedWorker::create(
68 new EmbeddedWorkerContextClient( 68 new EmbeddedWorkerContextClient(
69 embedded_worker_id, 69 embedded_worker_id,
70 service_worker_version_id, 70 service_worker_version_id,
71 script_url), 71 script_url),
72 NULL))); 72 NULL)));
73 73
74 blink::WebEmbeddedWorkerStartData start_data; 74 blink::WebEmbeddedWorkerStartData start_data;
75 start_data.scriptURL = script_url; 75 start_data.scriptURL = script_url;
76 start_data.userAgent = 76 start_data.userAgent = base::UTF8ToUTF16(GetUserAgent(script_url));
77 base::UTF8ToUTF16(webkit_glue::GetUserAgent(script_url));
78 start_data.startMode = blink::WebEmbeddedWorkerStartModeDontPauseOnStart; 77 start_data.startMode = blink::WebEmbeddedWorkerStartModeDontPauseOnStart;
79 78
80 wrapper->worker()->startWorkerContext(start_data); 79 wrapper->worker()->startWorkerContext(start_data);
81 workers_.AddWithID(wrapper.release(), embedded_worker_id); 80 workers_.AddWithID(wrapper.release(), embedded_worker_id);
82 } 81 }
83 82
84 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { 83 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) {
85 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); 84 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id);
86 if (!wrapper) { 85 if (!wrapper) {
87 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; 86 LOG(WARNING) << "Got OnStopWorker for nonexistent worker";
88 return; 87 return;
89 } 88 }
90 89
91 // This should eventually call WorkerContextDestroyed. (We may need to post 90 // This should eventually call WorkerContextDestroyed. (We may need to post
92 // a delayed task to forcibly abort the worker context if we find it 91 // a delayed task to forcibly abort the worker context if we find it
93 // necessary) 92 // necessary)
94 wrapper->worker()->terminateWorkerContext(); 93 wrapper->worker()->terminateWorkerContext();
95 } 94 }
96 95
97 } // namespace content 96 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698