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

Side by Side Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 182253010: Register a Service Worker when an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test passes! Don't know if it's right though 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/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
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,
62 this,
63 pattern,
64 script_url,
65 source_process_id,
66 continuation));
67 }
68
69 void ServiceWorkerContextWrapper::RegisterServiceWorkerOnIO(
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 base::Bind(&BrowserThread::PostTask,
90 BrowserThread::UI,
91 FROM_HERE,
92 base::Bind(continuation, status));
93 }
94
95 void ServiceWorkerContextWrapper::UnregisterServiceWorker(
96 const GURL& pattern,
97 int source_process_id,
98 const UnregistrationCallback& continuation) {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
100
101 BrowserThread::PostTask(
102 BrowserThread::IO,
103 FROM_HERE,
104 base::Bind(&ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO,
105 this,
106 pattern,
107 source_process_id,
108 continuation));
109 }
110
111 void ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO(
112 const GURL& pattern,
113 int source_process_id,
114 const UnregistrationCallback& continuation) {
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
116 context()->UnregisterServiceWorker(
117 pattern,
118 source_process_id,
119 base::Bind(&ServiceWorkerContextWrapper::FinishUnregistrationOnIO,
120 this,
121 continuation));
122 }
123 void ServiceWorkerContextWrapper::FinishUnregistrationOnIO(
124 const RegistrationCallback& continuation,
125 ServiceWorkerStatusCode status) {
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
127 base::Bind(&BrowserThread::PostTask,
128 BrowserThread::UI,
129 FROM_HERE,
130 base::Bind(continuation, status));
131 }
132
52 } // namespace content 133 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698