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

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

Issue 192283002: Revert 255858 "Simplify the user agent code some more since afte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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/content_client.h"
16 #include "content/renderer/render_thread_impl.h" 15 #include "content/renderer/render_thread_impl.h"
17 #include "content/renderer/service_worker/embedded_worker_context_client.h" 16 #include "content/renderer/service_worker/embedded_worker_context_client.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/WebURL.h" 18 #include "third_party/WebKit/public/platform/WebURL.h"
20 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h" 19 #include "third_party/WebKit/public/web/WebEmbeddedWorker.h"
21 #include "third_party/WebKit/public/web/WebEmbeddedWorkerStartData.h" 20 #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 = base::UTF8ToUTF16(GetContentClient()->GetUserAgent()); 76 start_data.userAgent =
77 base::UTF8ToUTF16(webkit_glue::GetUserAgent(script_url));
77 start_data.startMode = blink::WebEmbeddedWorkerStartModeDontPauseOnStart; 78 start_data.startMode = blink::WebEmbeddedWorkerStartModeDontPauseOnStart;
78 79
79 wrapper->worker()->startWorkerContext(start_data); 80 wrapper->worker()->startWorkerContext(start_data);
80 workers_.AddWithID(wrapper.release(), embedded_worker_id); 81 workers_.AddWithID(wrapper.release(), embedded_worker_id);
81 } 82 }
82 83
83 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { 84 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) {
84 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); 85 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id);
85 if (!wrapper) { 86 if (!wrapper) {
86 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; 87 LOG(WARNING) << "Got OnStopWorker for nonexistent worker";
87 return; 88 return;
88 } 89 }
89 90
90 // This should eventually call WorkerContextDestroyed. (We may need to post 91 // This should eventually call WorkerContextDestroyed. (We may need to post
91 // a delayed task to forcibly abort the worker context if we find it 92 // a delayed task to forcibly abort the worker context if we find it
92 // necessary) 93 // necessary)
93 wrapper->worker()->terminateWorkerContext(); 94 wrapper->worker()->terminateWorkerContext();
94 } 95 }
95 96
96 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698