OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/background_sync/background_sync_service_impl.h" | 5 #include "content/browser/background_sync/background_sync_service_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 DCHECK(background_sync_manager); | 120 DCHECK(background_sync_manager); |
121 background_sync_manager->GetRegistrations( | 121 background_sync_manager->GetRegistrations( |
122 sw_registration_id, | 122 sw_registration_id, |
123 base::Bind(&BackgroundSyncServiceImpl::OnGetRegistrationsResult, | 123 base::Bind(&BackgroundSyncServiceImpl::OnGetRegistrationsResult, |
124 weak_ptr_factory_.GetWeakPtr(), callback)); | 124 weak_ptr_factory_.GetWeakPtr(), callback)); |
125 } | 125 } |
126 | 126 |
127 void BackgroundSyncServiceImpl::OnRegisterResult( | 127 void BackgroundSyncServiceImpl::OnRegisterResult( |
128 const RegisterCallback& callback, | 128 const RegisterCallback& callback, |
129 BackgroundSyncStatus status, | 129 BackgroundSyncStatus status, |
130 scoped_ptr<BackgroundSyncRegistration> result) { | 130 std::unique_ptr<BackgroundSyncRegistration> result) { |
131 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 131 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
132 | 132 |
133 if (status != BACKGROUND_SYNC_STATUS_OK) { | 133 if (status != BACKGROUND_SYNC_STATUS_OK) { |
134 callback.Run( | 134 callback.Run( |
135 static_cast<content::mojom::BackgroundSyncError>(status), | 135 static_cast<content::mojom::BackgroundSyncError>(status), |
136 mojom::SyncRegistrationPtr(content::mojom::SyncRegistration::New())); | 136 mojom::SyncRegistrationPtr(content::mojom::SyncRegistration::New())); |
137 return; | 137 return; |
138 } | 138 } |
139 | 139 |
140 DCHECK(result); | 140 DCHECK(result); |
141 mojom::SyncRegistrationPtr mojoResult = ToMojoRegistration(*result); | 141 mojom::SyncRegistrationPtr mojoResult = ToMojoRegistration(*result); |
142 callback.Run(static_cast<content::mojom::BackgroundSyncError>(status), | 142 callback.Run(static_cast<content::mojom::BackgroundSyncError>(status), |
143 std::move(mojoResult)); | 143 std::move(mojoResult)); |
144 } | 144 } |
145 | 145 |
146 void BackgroundSyncServiceImpl::OnGetRegistrationsResult( | 146 void BackgroundSyncServiceImpl::OnGetRegistrationsResult( |
147 const GetRegistrationsCallback& callback, | 147 const GetRegistrationsCallback& callback, |
148 BackgroundSyncStatus status, | 148 BackgroundSyncStatus status, |
149 scoped_ptr<ScopedVector<BackgroundSyncRegistration>> result_registrations) { | 149 std::unique_ptr<ScopedVector<BackgroundSyncRegistration>> |
| 150 result_registrations) { |
150 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 151 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
151 DCHECK(result_registrations); | 152 DCHECK(result_registrations); |
152 | 153 |
153 mojo::Array<content::mojom::SyncRegistrationPtr> mojo_registrations; | 154 mojo::Array<content::mojom::SyncRegistrationPtr> mojo_registrations; |
154 for (const BackgroundSyncRegistration* registration : *result_registrations) | 155 for (const BackgroundSyncRegistration* registration : *result_registrations) |
155 mojo_registrations.push_back(ToMojoRegistration(*registration)); | 156 mojo_registrations.push_back(ToMojoRegistration(*registration)); |
156 | 157 |
157 callback.Run(static_cast<content::mojom::BackgroundSyncError>(status), | 158 callback.Run(static_cast<content::mojom::BackgroundSyncError>(status), |
158 std::move(mojo_registrations)); | 159 std::move(mojo_registrations)); |
159 } | 160 } |
160 | 161 |
161 } // namespace content | 162 } // namespace content |
OLD | NEW |