| 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 | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" | 12 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/extensions/api/dial.h" | 14 #include "chrome/common/extensions/api/dial.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
| 17 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
| 18 | 18 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 for (DialRegistry::DeviceList::const_iterator it = devices.begin(); | 102 for (DialRegistry::DeviceList::const_iterator it = devices.begin(); |
| 103 it != devices.end(); ++it) { | 103 it != devices.end(); ++it) { |
| 104 linked_ptr<api::dial::DialDevice> api_device = | 104 linked_ptr<api::dial::DialDevice> api_device = |
| 105 make_linked_ptr(new api::dial::DialDevice); | 105 make_linked_ptr(new api::dial::DialDevice); |
| 106 it->FillDialDevice(api_device.get()); | 106 it->FillDialDevice(api_device.get()); |
| 107 args.push_back(api_device); | 107 args.push_back(api_device); |
| 108 } | 108 } |
| 109 scoped_ptr<base::ListValue> results = api::dial::OnDeviceList::Create(args); | 109 scoped_ptr<base::ListValue> results = api::dial::OnDeviceList::Create(args); |
| 110 scoped_ptr<Event> event(new Event(events::DIAL_ON_DEVICE_LIST, | 110 scoped_ptr<Event> event(new Event(events::DIAL_ON_DEVICE_LIST, |
| 111 dial::OnDeviceList::kEventName, | 111 dial::OnDeviceList::kEventName, |
| 112 results.Pass())); | 112 std::move(results))); |
| 113 EventRouter::Get(profile_)->BroadcastEvent(event.Pass()); | 113 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) { | 116 void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) { |
| 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 118 | 118 |
| 119 api::dial::DialError dial_error; | 119 api::dial::DialError dial_error; |
| 120 switch (code) { | 120 switch (code) { |
| 121 case DialRegistry::DIAL_NO_LISTENERS: | 121 case DialRegistry::DIAL_NO_LISTENERS: |
| 122 dial_error.code = api::dial::DIAL_ERROR_CODE_NO_LISTENERS; | 122 dial_error.code = api::dial::DIAL_ERROR_CODE_NO_LISTENERS; |
| 123 break; | 123 break; |
| 124 case DialRegistry::DIAL_NO_INTERFACES: | 124 case DialRegistry::DIAL_NO_INTERFACES: |
| 125 dial_error.code = api::dial::DIAL_ERROR_CODE_NO_VALID_NETWORK_INTERFACES; | 125 dial_error.code = api::dial::DIAL_ERROR_CODE_NO_VALID_NETWORK_INTERFACES; |
| 126 break; | 126 break; |
| 127 case DialRegistry::DIAL_CELLULAR_NETWORK: | 127 case DialRegistry::DIAL_CELLULAR_NETWORK: |
| 128 dial_error.code = api::dial::DIAL_ERROR_CODE_CELLULAR_NETWORK; | 128 dial_error.code = api::dial::DIAL_ERROR_CODE_CELLULAR_NETWORK; |
| 129 break; | 129 break; |
| 130 case DialRegistry::DIAL_NETWORK_DISCONNECTED: | 130 case DialRegistry::DIAL_NETWORK_DISCONNECTED: |
| 131 dial_error.code = api::dial::DIAL_ERROR_CODE_NETWORK_DISCONNECTED; | 131 dial_error.code = api::dial::DIAL_ERROR_CODE_NETWORK_DISCONNECTED; |
| 132 break; | 132 break; |
| 133 case DialRegistry::DIAL_SOCKET_ERROR: | 133 case DialRegistry::DIAL_SOCKET_ERROR: |
| 134 dial_error.code = api::dial::DIAL_ERROR_CODE_SOCKET_ERROR; | 134 dial_error.code = api::dial::DIAL_ERROR_CODE_SOCKET_ERROR; |
| 135 break; | 135 break; |
| 136 default: | 136 default: |
| 137 dial_error.code = api::dial::DIAL_ERROR_CODE_UNKNOWN; | 137 dial_error.code = api::dial::DIAL_ERROR_CODE_UNKNOWN; |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 | 140 |
| 141 scoped_ptr<base::ListValue> results = api::dial::OnError::Create(dial_error); | 141 scoped_ptr<base::ListValue> results = api::dial::OnError::Create(dial_error); |
| 142 scoped_ptr<Event> event(new Event(events::DIAL_ON_ERROR, | 142 scoped_ptr<Event> event(new Event( |
| 143 dial::OnError::kEventName, results.Pass())); | 143 events::DIAL_ON_ERROR, dial::OnError::kEventName, std::move(results))); |
| 144 EventRouter::Get(profile_)->BroadcastEvent(event.Pass()); | 144 EventRouter::Get(profile_)->BroadcastEvent(std::move(event)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void DialAPI::ShutdownOnUIThread() {} | 147 void DialAPI::ShutdownOnUIThread() {} |
| 148 | 148 |
| 149 namespace api { | 149 namespace api { |
| 150 | 150 |
| 151 DialDiscoverNowFunction::DialDiscoverNowFunction() | 151 DialDiscoverNowFunction::DialDiscoverNowFunction() |
| 152 : dial_(NULL), result_(false) { | 152 : dial_(NULL), result_(false) { |
| 153 } | 153 } |
| 154 | 154 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 166 | 166 |
| 167 bool DialDiscoverNowFunction::Respond() { | 167 bool DialDiscoverNowFunction::Respond() { |
| 168 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 168 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 169 SetResult(new base::FundamentalValue(result_)); | 169 SetResult(new base::FundamentalValue(result_)); |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace api | 173 } // namespace api |
| 174 | 174 |
| 175 } // namespace extensions | 175 } // namespace extensions |
| OLD | NEW |