OLD | NEW |
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/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 NULL), | 88 NULL), |
89 params.worker_devtools_agent_route_id)); | 89 params.worker_devtools_agent_route_id)); |
90 | 90 |
91 blink::WebEmbeddedWorkerStartData start_data; | 91 blink::WebEmbeddedWorkerStartData start_data; |
92 start_data.scriptURL = params.script_url; | 92 start_data.scriptURL = params.script_url; |
93 start_data.userAgent = base::UTF8ToUTF16(GetContentClient()->GetUserAgent()); | 93 start_data.userAgent = base::UTF8ToUTF16(GetContentClient()->GetUserAgent()); |
94 start_data.waitForDebuggerMode = | 94 start_data.waitForDebuggerMode = |
95 params.wait_for_debugger ? | 95 params.wait_for_debugger ? |
96 blink::WebEmbeddedWorkerStartData::WaitForDebugger : | 96 blink::WebEmbeddedWorkerStartData::WaitForDebugger : |
97 blink::WebEmbeddedWorkerStartData::DontWaitForDebugger; | 97 blink::WebEmbeddedWorkerStartData::DontWaitForDebugger; |
98 start_data.v8CacheOptions = | 98 start_data.v8CacheOptions = static_cast<blink::WebSettings::V8CacheOptions>( |
99 static_cast<blink::WebSettings::V8CacheOptions>(params.v8_cache_options); | 99 params.settings.v8_cache_options); |
| 100 start_data.dataSaverEnabled = params.settings.data_saver_enabled; |
100 | 101 |
101 wrapper->worker()->startWorkerContext(start_data); | 102 wrapper->worker()->startWorkerContext(start_data); |
102 workers_.AddWithID(wrapper.release(), params.embedded_worker_id); | 103 workers_.AddWithID(wrapper.release(), params.embedded_worker_id); |
103 } | 104 } |
104 | 105 |
105 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { | 106 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { |
106 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker"); | 107 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker"); |
107 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); | 108 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); |
108 if (!wrapper) { | 109 if (!wrapper) { |
109 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; | 110 LOG(WARNING) << "Got OnStopWorker for nonexistent worker"; |
110 return; | 111 return; |
111 } | 112 } |
112 | 113 |
113 // This should eventually call WorkerContextDestroyed. (We may need to post | 114 // This should eventually call WorkerContextDestroyed. (We may need to post |
114 // a delayed task to forcibly abort the worker context if we find it | 115 // a delayed task to forcibly abort the worker context if we find it |
115 // necessary) | 116 // necessary) |
116 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); | 117 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); |
117 wrapper->worker()->terminateWorkerContext(); | 118 wrapper->worker()->terminateWorkerContext(); |
118 } | 119 } |
119 | 120 |
120 } // namespace content | 121 } // namespace content |
OLD | NEW |