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

Side by Side Diff: third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp

Issue 2774343002: Hook up BackgroundFetchServiceImpl::Fetch() to start a fetch (Closed)
Patch Set: rebase Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "modules/background_fetch/BackgroundFetchManager.h" 5 #include "modules/background_fetch/BackgroundFetchManager.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/V8ThrowException.h" 9 #include "bindings/core/v8/V8ThrowException.h"
10 #include "bindings/modules/v8/RequestOrUSVString.h" 10 #include "bindings/modules/v8/RequestOrUSVString.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 case mojom::blink::BackgroundFetchError::NONE: 75 case mojom::blink::BackgroundFetchError::NONE:
76 DCHECK(registration); 76 DCHECK(registration);
77 resolver->resolve(registration); 77 resolver->resolve(registration);
78 return; 78 return;
79 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG: 79 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG:
80 DCHECK(!registration); 80 DCHECK(!registration);
81 resolver->reject(DOMException::create( 81 resolver->reject(DOMException::create(
82 InvalidStateError, 82 InvalidStateError,
83 "There already is a registration for the given tag.")); 83 "There already is a registration for the given tag."));
84 return; 84 return;
85 case mojom::blink::BackgroundFetchError::INVALID_ARGUMENT:
85 case mojom::blink::BackgroundFetchError::INVALID_TAG: 86 case mojom::blink::BackgroundFetchError::INVALID_TAG:
86 // Not applicable for this callback. 87 // Not applicable for this callback.
87 break; 88 break;
88 } 89 }
89 90
90 NOTREACHED(); 91 NOTREACHED();
91 } 92 }
92 93
93 ScriptPromise BackgroundFetchManager::get(ScriptState* scriptState, 94 ScriptPromise BackgroundFetchManager::get(ScriptState* scriptState,
94 const String& tag) { 95 const String& tag) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 172
172 void BackgroundFetchManager::didGetRegistration( 173 void BackgroundFetchManager::didGetRegistration(
173 ScriptPromiseResolver* resolver, 174 ScriptPromiseResolver* resolver,
174 mojom::blink::BackgroundFetchError error, 175 mojom::blink::BackgroundFetchError error,
175 BackgroundFetchRegistration* registration) { 176 BackgroundFetchRegistration* registration) {
176 switch (error) { 177 switch (error) {
177 case mojom::blink::BackgroundFetchError::NONE: 178 case mojom::blink::BackgroundFetchError::NONE:
178 resolver->resolve(registration); 179 resolver->resolve(registration);
179 return; 180 return;
180 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG: 181 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG:
182 case mojom::blink::BackgroundFetchError::INVALID_ARGUMENT:
181 case mojom::blink::BackgroundFetchError::INVALID_TAG: 183 case mojom::blink::BackgroundFetchError::INVALID_TAG:
182 // Not applicable for this callback. 184 // Not applicable for this callback.
183 break; 185 break;
184 } 186 }
185 187
186 NOTREACHED(); 188 NOTREACHED();
187 } 189 }
188 190
189 ScriptPromise BackgroundFetchManager::getTags(ScriptState* scriptState) { 191 ScriptPromise BackgroundFetchManager::getTags(ScriptState* scriptState) {
190 if (!m_registration->active()) { 192 if (!m_registration->active()) {
(...skipping 15 matching lines...) Expand all
206 208
207 void BackgroundFetchManager::didGetTags( 209 void BackgroundFetchManager::didGetTags(
208 ScriptPromiseResolver* resolver, 210 ScriptPromiseResolver* resolver,
209 mojom::blink::BackgroundFetchError error, 211 mojom::blink::BackgroundFetchError error,
210 const Vector<String>& tags) { 212 const Vector<String>& tags) {
211 switch (error) { 213 switch (error) {
212 case mojom::blink::BackgroundFetchError::NONE: 214 case mojom::blink::BackgroundFetchError::NONE:
213 resolver->resolve(tags); 215 resolver->resolve(tags);
214 return; 216 return;
215 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG: 217 case mojom::blink::BackgroundFetchError::DUPLICATED_TAG:
218 case mojom::blink::BackgroundFetchError::INVALID_ARGUMENT:
216 case mojom::blink::BackgroundFetchError::INVALID_TAG: 219 case mojom::blink::BackgroundFetchError::INVALID_TAG:
217 // Not applicable for this callback. 220 // Not applicable for this callback.
218 break; 221 break;
219 } 222 }
220 223
221 NOTREACHED(); 224 NOTREACHED();
222 } 225 }
223 226
224 DEFINE_TRACE(BackgroundFetchManager) { 227 DEFINE_TRACE(BackgroundFetchManager) {
225 visitor->trace(m_registration); 228 visitor->trace(m_registration);
226 visitor->trace(m_bridge); 229 visitor->trace(m_bridge);
227 } 230 }
228 231
229 } // namespace blink 232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698