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 "extensions/browser/service_worker_manager.h" | 5 #include "extensions/browser/service_worker_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
9 #include "content/public/browser/service_worker_context.h" | 9 #include "content/public/browser/service_worker_context.h" |
10 #include "content/public/browser/storage_partition.h" | 10 #include "content/public/browser/storage_partition.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 // TODO(devlin): Technically, this can fail. We should ideally: | 41 // TODO(devlin): Technically, this can fail. We should ideally: |
42 // a) Keep track of extensions with registered service workers. | 42 // a) Keep track of extensions with registered service workers. |
43 // b) Add a callback to the (Un)SuspendServiceWorkersOnOrigin() method. | 43 // b) Add a callback to the (Un)SuspendServiceWorkersOnOrigin() method. |
44 // c) Check for any orphaned workers. | 44 // c) Check for any orphaned workers. |
45 content::BrowserContext::GetStoragePartitionForSite(browser_context_, | 45 content::BrowserContext::GetStoragePartitionForSite(browser_context_, |
46 extension->url()) | 46 extension->url()) |
47 ->GetServiceWorkerContext() | 47 ->GetServiceWorkerContext() |
48 ->DeleteForOrigin(extension->url(), base::Bind(&EmptySuccessCallback)); | 48 ->DeleteForOrigin(extension->url(), base::Bind(&EmptySuccessCallback)); |
49 } | 49 } |
50 | 50 |
51 void ServiceWorkerManager::OnExtensionWillBeInstalled( | |
52 content::BrowserContext* browser_context, | |
53 const Extension* extension, | |
54 bool is_update, | |
55 bool from_ephemeral, | |
56 const std::string& old_name) { | |
57 if (is_update) { | |
58 // TODO(lazyboy): This is racy because this relies on DeleteForOrigin() to | |
lazyboy
2015/11/10 00:45:44
How can we fix this?
Or, is there any guarantee th
Devlin
2015/11/10 16:59:50
Hmm... I would hope that it wouldn't be racy, beca
| |
59 // finish before updated extension (re)registers the service worker. | |
60 content::BrowserContext::GetStoragePartitionForSite(browser_context_, | |
61 extension->url()) | |
62 ->GetServiceWorkerContext() | |
63 ->DeleteForOrigin(extension->url(), base::Bind(&EmptySuccessCallback)); | |
Devlin
2015/11/10 16:59:50
(Sorry if this was just a placeholder and I'm sayi
lazyboy
2015/11/11 00:56:27
I've changed this to eventually call ServiceWorker
| |
64 } | |
65 } | |
66 | |
51 } // namespace extensions | 67 } // namespace extensions |
OLD | NEW |