Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/service_worker/service_worker_context_watcher.h" | 5 #include "content/browser/service_worker/service_worker_context_watcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 158 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 159 base::Bind(version_callback_, versions)); | 159 base::Bind(version_callback_, versions)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ServiceWorkerContextWatcher::OnNewLiveRegistration(int64_t registration_id, | 162 void ServiceWorkerContextWatcher::OnNewLiveRegistration(int64_t registration_id, |
| 163 const GURL& pattern) { | 163 const GURL& pattern) { |
| 164 SendRegistrationInfo(registration_id, pattern, | 164 SendRegistrationInfo(registration_id, pattern, |
| 165 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); | 165 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ServiceWorkerContextWatcher::OnNewLiveVersion(int64_t version_id, | 168 void ServiceWorkerContextWatcher::OnNewLiveVersion( |
| 169 int64_t registration_id, | 169 const ServiceWorkerVersionInfo& version_info) { |
| 170 const GURL& script_url) { | 170 int64_t version_id = version_info.version_id; |
| 171 if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) { | 171 if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) { |
| 172 DCHECK_EQ(version->registration_id, registration_id); | 172 DCHECK_EQ(version->registration_id, version_info.registration_id); |
| 173 DCHECK_EQ(version->script_url, script_url); | 173 DCHECK_EQ(version->script_url, version_info.script_url); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 std::unique_ptr<ServiceWorkerVersionInfo> version( | 177 std::unique_ptr<ServiceWorkerVersionInfo> version( |
| 178 new ServiceWorkerVersionInfo()); | 178 new ServiceWorkerVersionInfo(version_info)); |
| 179 version->version_id = version_id; | |
| 180 version->registration_id = registration_id; | |
| 181 version->script_url = script_url; | |
| 182 SendVersionInfo(*version); | 179 SendVersionInfo(*version); |
| 183 if (!IsStoppedAndRedundant(*version)) | 180 if (!IsStoppedAndRedundant(*version)) |
| 184 version_info_map_.set(version_id, std::move(version)); | 181 version_info_map_.set(version_id, std::move(version)); |
| 185 } | 182 } |
| 186 | 183 |
| 187 void ServiceWorkerContextWatcher::OnRunningStateChanged( | 184 void ServiceWorkerContextWatcher::OnRunningStateChanged( |
| 188 int64_t version_id, | 185 int64_t version_id, |
| 189 content::EmbeddedWorkerStatus running_status) { | 186 content::EmbeddedWorkerStatus running_status) { |
| 190 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | 187 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); |
| 191 DCHECK(version); | 188 DCHECK(version); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 203 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | 200 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); |
| 204 DCHECK(version); | 201 DCHECK(version); |
| 205 if (version->status == status) | 202 if (version->status == status) |
| 206 return; | 203 return; |
| 207 version->status = status; | 204 version->status = status; |
| 208 SendVersionInfo(*version); | 205 SendVersionInfo(*version); |
| 209 if (IsStoppedAndRedundant(*version)) | 206 if (IsStoppedAndRedundant(*version)) |
| 210 version_info_map_.erase(version_id); | 207 version_info_map_.erase(version_id); |
| 211 } | 208 } |
| 212 | 209 |
| 210 void ServiceWorkerContextWatcher::OnVersionRoutingIdsChanged( | |
|
horo
2016/09/26 01:30:05
OnVersionDevToolsRoutingIdChanged
dgozman
2016/09/26 15:49:12
Done.
| |
| 211 int64_t version_id, | |
| 212 int process_id, | |
| 213 int devtools_agent_route_id) { | |
| 214 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | |
| 215 DCHECK(version); | |
| 216 if (version->process_id == process_id && | |
| 217 version->devtools_agent_route_id == devtools_agent_route_id) { | |
| 218 return; | |
| 219 } | |
| 220 version->process_id = process_id; | |
| 221 version->devtools_agent_route_id = devtools_agent_route_id; | |
| 222 SendVersionInfo(*version); | |
| 223 if (IsStoppedAndRedundant(*version)) | |
| 224 version_info_map_.erase(version_id); | |
| 225 } | |
| 226 | |
| 213 void ServiceWorkerContextWatcher::OnMainScriptHttpResponseInfoSet( | 227 void ServiceWorkerContextWatcher::OnMainScriptHttpResponseInfoSet( |
| 214 int64_t version_id, | 228 int64_t version_id, |
| 215 base::Time script_response_time, | 229 base::Time script_response_time, |
| 216 base::Time script_last_modified) { | 230 base::Time script_last_modified) { |
| 217 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | 231 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); |
| 218 DCHECK(version); | 232 DCHECK(version); |
| 219 version->script_response_time = script_response_time; | 233 version->script_response_time = script_response_time; |
| 220 version->script_last_modified = script_last_modified; | 234 version->script_last_modified = script_last_modified; |
| 221 SendVersionInfo(*version); | 235 SendVersionInfo(*version); |
| 222 } | 236 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); | 292 ServiceWorkerRegistrationInfo::IS_NOT_DELETED); |
| 279 } | 293 } |
| 280 | 294 |
| 281 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64_t registration_id, | 295 void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64_t registration_id, |
| 282 const GURL& pattern) { | 296 const GURL& pattern) { |
| 283 SendRegistrationInfo(registration_id, pattern, | 297 SendRegistrationInfo(registration_id, pattern, |
| 284 ServiceWorkerRegistrationInfo::IS_DELETED); | 298 ServiceWorkerRegistrationInfo::IS_DELETED); |
| 285 } | 299 } |
| 286 | 300 |
| 287 } // namespace content | 301 } // namespace content |
| OLD | NEW |