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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_api.cc

Issue 2702503003: [Dial] Refactor DialRegistry and DeviceDescriptionFetcher so they can be used by MediaSinkService (Closed)
Patch Set: Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/dial/dial_api.h" 5 #include "chrome/browser/extensions/api/dial/dial_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return; 223 return;
224 } 224 }
225 225
226 if (dial_->test_device_data_ && dial_->test_device_description_ && 226 if (dial_->test_device_data_ && dial_->test_device_description_ &&
227 dial_->test_device_data_->device_description_url() == url) { 227 dial_->test_device_data_->device_description_url() == url) {
228 OnFetchComplete(*(dial_->test_device_description_)); 228 OnFetchComplete(*(dial_->test_device_description_));
229 return; 229 return;
230 } 230 }
231 231
232 device_description_fetcher_ = base::MakeUnique<DeviceDescriptionFetcher>( 232 device_description_fetcher_ = base::MakeUnique<DeviceDescriptionFetcher>(
233 url, Profile::FromBrowserContext(browser_context()), 233 url, Profile::FromBrowserContext(browser_context())->GetRequestContext(),
234 BrowserThread::UI,
234 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchComplete, 235 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchComplete,
235 this), 236 this),
236 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchError, this)); 237 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchError, this));
237 238
238 device_description_fetcher_->Start(); 239 device_description_fetcher_->Start();
239 } 240 }
240 241
241 void DialFetchDeviceDescriptionFunction::OnFetchComplete( 242 void DialFetchDeviceDescriptionFunction::OnFetchComplete(
242 const api::dial::DialDeviceDescriptionData& result) { 243 const api::dial::DialDeviceDescriptionData& result) {
243 // Destroy the DeviceDescriptionFetcher since it still contains a reference 244 // Destroy the DeviceDescriptionFetcher since it still contains a reference
(...skipping 10 matching lines...) Expand all
254 void DialFetchDeviceDescriptionFunction::OnFetchError( 255 void DialFetchDeviceDescriptionFunction::OnFetchError(
255 const std::string& message) { 256 const std::string& message) {
256 // Destroy the DeviceDescriptionFetcher since it still contains a reference 257 // Destroy the DeviceDescriptionFetcher since it still contains a reference
257 // to |this| in its un-invoked callback. 258 // to |this| in its un-invoked callback.
258 device_description_fetcher_.reset(); 259 device_description_fetcher_.reset();
259 SetError(message); 260 SetError(message);
260 SendResponse(false); 261 SendResponse(false);
261 } 262 }
262 263
263 } // namespace extensions 264 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698