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/browser/service_worker/service_worker_context_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "webkit/browser/quota/quota_manager_proxy.h" | 10 #include "webkit/browser/quota/quota_manager_proxy.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 return; | 42 return; |
43 } | 43 } |
44 context_core_.reset(); | 44 context_core_.reset(); |
45 } | 45 } |
46 | 46 |
47 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 47 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
49 return context_core_.get(); | 49 return context_core_.get(); |
50 } | 50 } |
51 | 51 |
52 void ServiceWorkerContextWrapper::RegisterServiceWorker( | |
53 const GURL& pattern, | |
54 const GURL& script_url, | |
55 int source_process_id, | |
56 const RegistrationCallback& continuation) { | |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
58 BrowserThread::PostTask( | |
59 BrowserThread::IO, | |
60 FROM_HERE, | |
61 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorkerOnIO, | |
kinuko
2014/03/26 05:01:34
Instead of having yet another indirection method w
Jeffrey Yasskin
2014/03/26 19:58:52
Sure, done.
| |
62 this, | |
63 pattern, | |
64 script_url, | |
65 source_process_id, | |
66 continuation)); | |
67 } | |
68 | |
69 void ServiceWorkerContextWrapper::RegisterServiceWorkerOnIO( | |
kinuko
2014/03/26 05:01:34
I know this ordering has some benfits, but can we
Jeffrey Yasskin
2014/03/26 19:58:52
Obsolete now.
| |
70 const GURL& pattern, | |
71 const GURL& script_url, | |
72 int source_process_id, | |
73 const RegistrationCallback& continuation) { | |
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
75 context()->RegisterServiceWorker( | |
76 pattern, | |
77 script_url, | |
78 source_process_id, | |
79 base::Bind(&ServiceWorkerContextWrapper::FinishRegistrationOnIO, | |
80 this, | |
81 continuation)); | |
82 } | |
83 | |
84 void ServiceWorkerContextWrapper::FinishRegistrationOnIO( | |
85 const RegistrationCallback& continuation, | |
86 ServiceWorkerStatusCode status, | |
87 int64 registration_id) { | |
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
89 BrowserThread::PostTask( | |
90 BrowserThread::UI, FROM_HERE, base::Bind(continuation, status)); | |
91 } | |
92 | |
93 void ServiceWorkerContextWrapper::UnregisterServiceWorker( | |
94 const GURL& pattern, | |
95 int source_process_id, | |
96 const UnregistrationCallback& continuation) { | |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
98 | |
99 BrowserThread::PostTask( | |
100 BrowserThread::IO, | |
101 FROM_HERE, | |
102 base::Bind(&ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO, | |
103 this, | |
104 pattern, | |
105 source_process_id, | |
106 continuation)); | |
107 } | |
108 | |
109 void ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO( | |
110 const GURL& pattern, | |
111 int source_process_id, | |
112 const UnregistrationCallback& continuation) { | |
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
114 context()->UnregisterServiceWorker( | |
115 pattern, | |
116 source_process_id, | |
117 base::Bind(&ServiceWorkerContextWrapper::FinishUnregistrationOnIO, | |
118 this, | |
119 continuation)); | |
120 } | |
121 void ServiceWorkerContextWrapper::FinishUnregistrationOnIO( | |
122 const RegistrationCallback& continuation, | |
123 ServiceWorkerStatusCode status) { | |
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
125 BrowserThread::PostTask( | |
126 BrowserThread::UI, FROM_HERE, base::Bind(continuation, status)); | |
127 } | |
128 | |
52 } // namespace content | 129 } // namespace content |
OLD | NEW |