| OLD | NEW |
| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 url, Profile::FromBrowserContext(browser_context()), | 233 url, Profile::FromBrowserContext(browser_context()), |
| 234 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchComplete, | 234 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchComplete, |
| 235 this), | 235 this), |
| 236 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchError, this)); | 236 base::BindOnce(&DialFetchDeviceDescriptionFunction::OnFetchError, this)); |
| 237 | 237 |
| 238 device_description_fetcher_->Start(); | 238 device_description_fetcher_->Start(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void DialFetchDeviceDescriptionFunction::OnFetchComplete( | 241 void DialFetchDeviceDescriptionFunction::OnFetchComplete( |
| 242 const api::dial::DialDeviceDescriptionData& result) { | 242 const api::dial::DialDeviceDescriptionData& result) { |
| 243 // Destroy the DeviceDescriptionFetcher since it still contains a reference |
| 244 // to |this| in its un-invoked callback. |
| 245 device_description_fetcher_.reset(); |
| 243 api::dial::DialDeviceDescription device_description; | 246 api::dial::DialDeviceDescription device_description; |
| 244 device_description.device_label = params_->device_label; | 247 device_description.device_label = params_->device_label; |
| 245 device_description.app_url = result.app_url.spec(); | 248 device_description.app_url = result.app_url.spec(); |
| 246 device_description.device_description = result.device_description; | 249 device_description.device_description = result.device_description; |
| 247 SetResult(device_description.ToValue()); | 250 SetResult(device_description.ToValue()); |
| 248 SendResponse(true); | 251 SendResponse(true); |
| 249 } | 252 } |
| 250 | 253 |
| 251 void DialFetchDeviceDescriptionFunction::OnFetchError( | 254 void DialFetchDeviceDescriptionFunction::OnFetchError( |
| 252 const std::string& message) { | 255 const std::string& message) { |
| 256 // Destroy the DeviceDescriptionFetcher since it still contains a reference |
| 257 // to |this| in its un-invoked callback. |
| 258 device_description_fetcher_.reset(); |
| 253 SetError(message); | 259 SetError(message); |
| 254 SendResponse(false); | 260 SendResponse(false); |
| 255 } | 261 } |
| 256 | 262 |
| 257 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |