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

Side by Side Diff: Source/modules/geofencing/Geofencing.cpp

Issue 783423003: Make ScriptPromiseResolver RefCountedWillBeRefCountedGarbageCollected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP: 1st trial Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "modules/geofencing/Geofencing.h" 6 #include "modules/geofencing/Geofencing.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 : m_registration(registration) 51 : m_registration(registration)
52 { 52 {
53 } 53 }
54 54
55 ScriptPromise Geofencing::registerRegion(ScriptState* scriptState, GeofencingReg ion* region) 55 ScriptPromise Geofencing::registerRegion(ScriptState* scriptState, GeofencingReg ion* region)
56 { 56 {
57 WebGeofencingProvider* provider = Platform::current()->geofencingProvider(); 57 WebGeofencingProvider* provider = Platform::current()->geofencingProvider();
58 if (!provider) 58 if (!provider)
59 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 59 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
60 60
61 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 61 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
62 ScriptPromise promise = resolver->promise(); 62 ScriptPromise promise = resolver->promise();
63 WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, Geofenc ingError>(resolver); 63 WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, Geofenc ingError>(resolver);
64 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr; 64 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
65 if (m_registration) 65 if (m_registration)
66 serviceWorkerRegistration = m_registration->webRegistration(); 66 serviceWorkerRegistration = m_registration->webRegistration();
67 provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->w ebRegion(), serviceWorkerRegistration, callbacks); 67 provider->registerRegion(region->id(), toCircularGeofencingRegion(region)->w ebRegion(), serviceWorkerRegistration, callbacks);
68 return promise; 68 return promise;
69 } 69 }
70 70
71 ScriptPromise Geofencing::unregisterRegion(ScriptState* scriptState, const Strin g& regionId) 71 ScriptPromise Geofencing::unregisterRegion(ScriptState* scriptState, const Strin g& regionId)
72 { 72 {
73 WebGeofencingProvider* provider = Platform::current()->geofencingProvider(); 73 WebGeofencingProvider* provider = Platform::current()->geofencingProvider();
74 if (!provider) 74 if (!provider)
75 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 75 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
76 76
77 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 77 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
78 ScriptPromise promise = resolver->promise(); 78 ScriptPromise promise = resolver->promise();
79 WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, Geofenc ingError>(resolver); 79 WebGeofencingCallbacks* callbacks = new CallbackPromiseAdapter<void, Geofenc ingError>(resolver);
80 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr; 80 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
81 if (m_registration) 81 if (m_registration)
82 serviceWorkerRegistration = m_registration->webRegistration(); 82 serviceWorkerRegistration = m_registration->webRegistration();
83 provider->unregisterRegion(regionId, serviceWorkerRegistration, callbacks); 83 provider->unregisterRegion(regionId, serviceWorkerRegistration, callbacks);
84 return promise; 84 return promise;
85 } 85 }
86 86
87 ScriptPromise Geofencing::getRegisteredRegions(ScriptState* scriptState) const 87 ScriptPromise Geofencing::getRegisteredRegions(ScriptState* scriptState) const
88 { 88 {
89 WebGeofencingProvider* provider = Platform::current()->geofencingProvider(); 89 WebGeofencingProvider* provider = Platform::current()->geofencingProvider();
90 if (!provider) 90 if (!provider)
91 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError)); 91 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError));
92 92
93 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 93 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
94 ScriptPromise promise = resolver->promise(); 94 ScriptPromise promise = resolver->promise();
95 WebGeofencingRegionsCallbacks* callbacks = new CallbackPromiseAdapter<Region Array, GeofencingError>(resolver); 95 WebGeofencingRegionsCallbacks* callbacks = new CallbackPromiseAdapter<Region Array, GeofencingError>(resolver);
96 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr; 96 WebServiceWorkerRegistration* serviceWorkerRegistration = nullptr;
97 if (m_registration) 97 if (m_registration)
98 serviceWorkerRegistration = m_registration->webRegistration(); 98 serviceWorkerRegistration = m_registration->webRegistration();
99 provider->getRegisteredRegions(serviceWorkerRegistration, callbacks); 99 provider->getRegisteredRegions(serviceWorkerRegistration, callbacks);
100 return promise; 100 return promise;
101 } 101 }
102 102
103 void Geofencing::trace(Visitor* visitor) 103 void Geofencing::trace(Visitor* visitor)
104 { 104 {
105 visitor->trace(m_registration); 105 visitor->trace(m_registration);
106 } 106 }
107 107
108 } // namespace blink 108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698