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

Unified Diff: Source/modules/background_sync/SyncCallbacks.cpp

Issue 1311053002: [BackgroundSync] Use appopriate type parameters for WebCallbacks (2/4) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/background_sync/SyncCallbacks.h ('k') | Source/modules/background_sync/SyncError.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/background_sync/SyncCallbacks.cpp
diff --git a/Source/modules/background_sync/SyncCallbacks.cpp b/Source/modules/background_sync/SyncCallbacks.cpp
index d7ec505b82ef1db4a7edf4549da6c32bc332aa29..016120c83640c37d89e54e3959879e2481102358 100644
--- a/Source/modules/background_sync/SyncCallbacks.cpp
+++ b/Source/modules/background_sync/SyncCallbacks.cpp
@@ -1,4 +1,4 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
jkarlin 2015/08/24 11:50:09 Why this change?
yhirano 2015/08/24 14:07:39 Sorry, this was not intended. Fixed.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,31 +27,30 @@ SyncRegistrationCallbacks::~SyncRegistrationCallbacks()
{
}
-void SyncRegistrationCallbacks::onSuccess(WebSyncRegistration* webSyncRegistration)
+void SyncRegistrationCallbacks::onSuccess(WebPassOwnPtr<WebSyncRegistration> webSyncRegistration)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncRegistration::dispose(webSyncRegistration);
return;
}
- if (!webSyncRegistration) {
+ OwnPtr<WebSyncRegistration> registration = webSyncRegistration.release();
+ if (!registration) {
m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
return;
}
- switch (webSyncRegistration->periodicity) {
+ switch (registration->periodicity) {
case WebSyncRegistration::PeriodicityPeriodic:
- m_resolver->resolve(PeriodicSyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
+ m_resolver->resolve(PeriodicSyncRegistration::take(m_resolver.get(), registration.release(), m_serviceWorkerRegistration));
break;
case WebSyncRegistration::PeriodicityOneShot:
- m_resolver->resolve(SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
+ m_resolver->resolve(SyncRegistration::take(m_resolver.get(), registration.release(), m_serviceWorkerRegistration));
break;
}
}
-void SyncRegistrationCallbacks::onError(WebSyncError* error)
+void SyncRegistrationCallbacks::onError(const WebSyncError& error)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncError::dispose(error);
return;
}
m_resolver->reject(SyncError::take(m_resolver.get(), error));
@@ -69,20 +68,18 @@ SyncNotifyWhenDoneCallbacks::~SyncNotifyWhenDoneCallbacks()
{
}
-void SyncNotifyWhenDoneCallbacks::onSuccess(bool* status)
+void SyncNotifyWhenDoneCallbacks::onSuccess(bool status)
{
- OwnPtr<bool> statusPtr = adoptPtr(status);
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
return;
}
- m_resolver->resolve(*status);
+ m_resolver->resolve(status);
}
-void SyncNotifyWhenDoneCallbacks::onError(WebSyncError* error)
+void SyncNotifyWhenDoneCallbacks::onError(const WebSyncError& error)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncError::dispose(error);
return;
}
m_resolver->reject(SyncError::take(m_resolver.get(), error));
@@ -100,20 +97,18 @@ SyncUnregistrationCallbacks::~SyncUnregistrationCallbacks()
{
}
-void SyncUnregistrationCallbacks::onSuccess(bool* status)
+void SyncUnregistrationCallbacks::onSuccess(bool status)
{
- OwnPtr<bool> statusPtr = adoptPtr(status);
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
return;
}
- m_resolver->resolve(*status);
+ m_resolver->resolve(status);
}
-void SyncUnregistrationCallbacks::onError(WebSyncError* error)
+void SyncUnregistrationCallbacks::onError(const WebSyncError& error)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncError::dispose(error);
return;
}
m_resolver->reject(SyncError::take(m_resolver.get(), error));
@@ -131,47 +126,36 @@ SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks()
{
}
-void SyncGetRegistrationsCallbacks::onSuccess(WebVector<WebSyncRegistration*>* webSyncRegistrations)
+void SyncGetRegistrationsCallbacks::onSuccess(const WebVector<WebSyncRegistration*>& webSyncRegistrations)
{
- if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- if (webSyncRegistrations) {
- for (size_t i = 0; i < webSyncRegistrations->size(); ++i)
- SyncRegistration::dispose((*webSyncRegistrations)[i]);
- delete (webSyncRegistrations);
- }
- return;
+ Vector<OwnPtr<WebSyncRegistration>> registrations;
+ for (WebSyncRegistration* r : webSyncRegistrations) {
+ registrations.append(adoptPtr(r));
}
-
- if (!webSyncRegistrations) {
- m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
return;
}
- if (webSyncRegistrations->size() && (*webSyncRegistrations)[0]->periodicity == WebSyncRegistration::PeriodicityOneShot) {
+ if (webSyncRegistrations.size() && webSyncRegistrations[0]->periodicity == WebSyncRegistration::PeriodicityOneShot) {
Vector<SyncRegistration*> syncRegistrations;
- for (size_t i = 0; i < webSyncRegistrations->size(); ++i) {
- WebSyncRegistration* webSyncRegistration = (*webSyncRegistrations)[i];
- SyncRegistration* reg = SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration);
+ for (auto& r : registrations) {
+ SyncRegistration* reg = SyncRegistration::take(m_resolver.get(), r.release(), m_serviceWorkerRegistration);
syncRegistrations.append(reg);
}
- delete (webSyncRegistrations);
m_resolver->resolve(syncRegistrations);
} else {
Vector<PeriodicSyncRegistration*> syncRegistrations;
- for (size_t i = 0; i < webSyncRegistrations->size(); ++i) {
- WebSyncRegistration* webSyncRegistration = (*webSyncRegistrations)[i];
- PeriodicSyncRegistration* reg = PeriodicSyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration);
+ for (auto& r : registrations) {
+ PeriodicSyncRegistration* reg = PeriodicSyncRegistration::take(m_resolver.get(), r.release(), m_serviceWorkerRegistration);
syncRegistrations.append(reg);
}
- delete (webSyncRegistrations);
m_resolver->resolve(syncRegistrations);
}
}
-void SyncGetRegistrationsCallbacks::onError(WebSyncError* error)
+void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncError::dispose(error);
return;
}
m_resolver->reject(SyncError::take(m_resolver.get(), error));
@@ -189,20 +173,18 @@ SyncGetPermissionStatusCallbacks::~SyncGetPermissionStatusCallbacks()
{
}
-void SyncGetPermissionStatusCallbacks::onSuccess(WebSyncPermissionStatus* status)
+void SyncGetPermissionStatusCallbacks::onSuccess(WebSyncPermissionStatus status)
{
- OwnPtr<WebSyncPermissionStatus> statusPtr = adoptPtr(status);
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
return;
}
- m_resolver->resolve(permissionString(*statusPtr));
+ m_resolver->resolve(permissionString(status));
}
-void SyncGetPermissionStatusCallbacks::onError(WebSyncError* error)
+void SyncGetPermissionStatusCallbacks::onError(const WebSyncError& error)
{
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
- SyncError::dispose(error);
return;
}
m_resolver->reject(SyncError::take(m_resolver.get(), error));
« no previous file with comments | « Source/modules/background_sync/SyncCallbacks.h ('k') | Source/modules/background_sync/SyncError.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698