| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 void DialAPI::OnDialError(const DialRegistry::DialErrorCode code) { | 92 void DialAPI::OnDialError(const DialRegistry::DialErrorCode code) { |
| 93 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 93 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 94 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 94 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 95 base::Bind(&DialAPI::SendErrorOnUIThread, this, code)); | 95 base::Bind(&DialAPI::SendErrorOnUIThread, this, code)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void DialAPI::SendEventOnUIThread(const DialRegistry::DeviceList& devices) { | 98 void DialAPI::SendEventOnUIThread(const DialRegistry::DeviceList& devices) { |
| 99 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 99 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 100 | 100 |
| 101 std::vector<linked_ptr<api::dial::DialDevice> > args; | 101 std::vector<api::dial::DialDevice> args; |
| 102 for (DialRegistry::DeviceList::const_iterator it = devices.begin(); | 102 for (const DialDeviceData& device : devices) { |
| 103 it != devices.end(); ++it) { | 103 api::dial::DialDevice api_device; |
| 104 linked_ptr<api::dial::DialDevice> api_device = | 104 device.FillDialDevice(&api_device); |
| 105 make_linked_ptr(new api::dial::DialDevice); | 105 args.push_back(std::move(api_device)); |
| 106 it->FillDialDevice(api_device.get()); | |
| 107 args.push_back(api_device); | |
| 108 } | 106 } |
| 109 scoped_ptr<base::ListValue> results = api::dial::OnDeviceList::Create(args); | 107 scoped_ptr<base::ListValue> results = api::dial::OnDeviceList::Create(args); |
| 110 scoped_ptr<Event> event(new Event(events::DIAL_ON_DEVICE_LIST, | 108 scoped_ptr<Event> event(new Event(events::DIAL_ON_DEVICE_LIST, |
| 111 dial::OnDeviceList::kEventName, | 109 dial::OnDeviceList::kEventName, |
| 112 std::move(results))); | 110 std::move(results))); |
| 113 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); | 111 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); |
| 114 } | 112 } |
| 115 | 113 |
| 116 void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) { | 114 void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) { |
| 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 115 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 164 |
| 167 bool DialDiscoverNowFunction::Respond() { | 165 bool DialDiscoverNowFunction::Respond() { |
| 168 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 166 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 169 SetResult(new base::FundamentalValue(result_)); | 167 SetResult(new base::FundamentalValue(result_)); |
| 170 return true; | 168 return true; |
| 171 } | 169 } |
| 172 | 170 |
| 173 } // namespace api | 171 } // namespace api |
| 174 | 172 |
| 175 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |