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

Side by Side Diff: content/browser/background_sync/background_sync_service_impl.cc

Issue 1316743002: Reland of [Background Sync] Allow sync manager access from uncontrolled clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 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 "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "content/browser/background_sync/background_sync_context_impl.h" 8 #include "content/browser/background_sync/background_sync_context_impl.h"
9 #include "content/browser/background_sync/background_sync_registration.h" 9 #include "content/browser/background_sync/background_sync_registration.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 base::Unretained(this) /* the channel is owned by this */)); 104 base::Unretained(this) /* the channel is owned by this */));
105 } 105 }
106 106
107 void BackgroundSyncServiceImpl::OnConnectionError() { 107 void BackgroundSyncServiceImpl::OnConnectionError() {
108 background_sync_context_->ServiceHadConnectionError(this); 108 background_sync_context_->ServiceHadConnectionError(this);
109 // |this| is now deleted. 109 // |this| is now deleted.
110 } 110 }
111 111
112 void BackgroundSyncServiceImpl::Register(content::SyncRegistrationPtr options, 112 void BackgroundSyncServiceImpl::Register(content::SyncRegistrationPtr options,
113 int64_t sw_registration_id, 113 int64_t sw_registration_id,
114 bool requested_from_service_worker,
114 const RegisterCallback& callback) { 115 const RegisterCallback& callback) {
115 DCHECK_CURRENTLY_ON(BrowserThread::IO); 116 DCHECK_CURRENTLY_ON(BrowserThread::IO);
116 117
117 BackgroundSyncRegistrationOptions mgr_options = 118 BackgroundSyncRegistrationOptions mgr_options =
118 ToBackgroundSyncRegistrationOptions(options); 119 ToBackgroundSyncRegistrationOptions(options);
119 120
120 BackgroundSyncManager* background_sync_manager = 121 BackgroundSyncManager* background_sync_manager =
121 background_sync_context_->background_sync_manager(); 122 background_sync_context_->background_sync_manager();
122 DCHECK(background_sync_manager); 123 DCHECK(background_sync_manager);
123 background_sync_manager->Register( 124 background_sync_manager->Register(
124 sw_registration_id, mgr_options, 125 sw_registration_id, mgr_options, requested_from_service_worker,
125 base::Bind(&BackgroundSyncServiceImpl::OnRegisterResult, 126 base::Bind(&BackgroundSyncServiceImpl::OnRegisterResult,
126 weak_ptr_factory_.GetWeakPtr(), callback)); 127 weak_ptr_factory_.GetWeakPtr(), callback));
127 } 128 }
128 129
129 void BackgroundSyncServiceImpl::Unregister( 130 void BackgroundSyncServiceImpl::Unregister(
130 BackgroundSyncPeriodicity periodicity, 131 BackgroundSyncPeriodicity periodicity,
131 int64_t id, 132 int64_t id,
132 const mojo::String& tag, 133 const mojo::String& tag,
133 int64_t sw_registration_id, 134 int64_t sw_registration_id,
134 const UnregisterCallback& callback) { 135 const UnregisterCallback& callback) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const std::vector<BackgroundSyncRegistration>& result_registrations) { 207 const std::vector<BackgroundSyncRegistration>& result_registrations) {
207 DCHECK_CURRENTLY_ON(BrowserThread::IO); 208 DCHECK_CURRENTLY_ON(BrowserThread::IO);
208 mojo::Array<content::SyncRegistrationPtr> mojo_registrations(0); 209 mojo::Array<content::SyncRegistrationPtr> mojo_registrations(0);
209 for (const auto& registration : result_registrations) 210 for (const auto& registration : result_registrations)
210 mojo_registrations.push_back(ToMojoRegistration(registration)); 211 mojo_registrations.push_back(ToMojoRegistration(registration));
211 callback.Run(static_cast<content::BackgroundSyncError>(status), 212 callback.Run(static_cast<content::BackgroundSyncError>(status),
212 mojo_registrations.Pass()); 213 mojo_registrations.Pass());
213 } 214 }
214 215
215 } // namespace content 216 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698