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

Side by Side Diff: Source/modules/background_sync/SyncManager.cpp

Issue 963683002: Add IDL and initial Blink API for Background Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remembering how ASCII works Created 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/background_sync/SyncManager.h"
7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h"
11 #include "bindings/core/v8/ScriptState.h"
12 #include "core/dom/DOMException.h"
13 #include "core/dom/Document.h"
14 #include "core/dom/ExceptionCode.h"
15 #include "core/dom/ExecutionContext.h"
16 #include "modules/background_sync/SyncRegistrationCallbacks.h"
17 #include "modules/background_sync/SyncRegistrationOptions.h"
18 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
19 #include "public/platform/Platform.h"
20 #include "public/platform/modules/background_sync/WebSyncProvider.h"
21 #include "wtf/RefPtr.h"
22
23
24 namespace blink {
25 namespace {
26
27 WebSyncProvider* backgroundSyncProvider()
jkarlin 2015/02/27 20:08:13 contents of nested namespaces in blink are indente
iclelland 2015/03/02 03:51:11 Done.
28 {
29 WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvid er();
30 ASSERT(webSyncProvider);
31 return webSyncProvider;
32 }
33
34 } // namespace
jkarlin 2015/02/27 20:08:12 don't need the '// namespace' as this is such a sh
iclelland 2015/03/02 03:51:11 Done.
35
36 unsigned long SyncManager::minAllowablePeriod()
37 {
38 return m_minAllowablePeriod;
jkarlin 2015/02/27 20:08:13 return a constant defined in the unnamed namespace
iclelland 2015/03/02 03:51:11 Done.
39 }
40
41 ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState)
jkarlin 2015/02/27 20:08:12 I don't think you need this method
iclelland 2015/03/02 03:51:11 No, actually, I don't think we do. I was told earl
42 {
43 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
44 ScriptPromise promise = resolver->promise();
45
46 backgroundSyncProvider()->registerBackgroundSync(0, new SyncRegistrationCall backs(resolver, m_registration));
47
48 return promise;
49 }
50
51 ScriptPromise SyncManager::registerFunction(blink::ScriptState* scriptState, con st SyncRegistrationOptions& options)
52 {
53 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
54 ScriptPromise promise = resolver->promise();
55
56 backgroundSyncProvider()->registerBackgroundSync(0, new SyncRegistrationCall backs(resolver, m_registration));
jkarlin 2015/02/27 20:08:12 Please see PushManager::subscribe. They have a che
iclelland 2015/03/02 03:51:11 Right -- I thought that one of the concerns was th
57
58 return promise;
59 }
60
61 ScriptPromise SyncManager::getRegistrations(blink::ScriptState* scriptState)
62 {
63 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
64 ScriptPromise promise = resolver->promise();
65
66 // Don't have anything useful to do ATM
67 resolver->reject(DOMException::create(InvalidStateError, "Not implemented")) ;
jkarlin 2015/02/27 20:08:13 Use NotSupportedError
iclelland 2015/03/02 03:51:11 Sure -- this isn't intended to survive by the time
68
69 return promise;
70 }
71
72 void SyncManager::trace(Visitor *visitor)
jkarlin 2015/02/27 20:08:13 DEFINE_TRACE(SyncManager)
iclelland 2015/03/02 03:51:11 Done.
73 {
74 visitor->trace(m_registration);
75 }
76
77 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698