| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" | 10 #include "chrome/browser/extensions/api/dial/dial_api_factory.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/extensions/api/dial.h" | 12 #include "chrome/common/extensions/api/dial.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
| 15 #include "extensions/browser/extension_system.h" | 15 #include "extensions/browser/extension_system.h" |
| 16 | 16 |
| 17 using base::TimeDelta; | 17 using base::TimeDelta; |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kDialServiceError[] = "Dial service error."; | |
| 23 | |
| 24 // How often to poll for devices. | 22 // How often to poll for devices. |
| 25 const int kDialRefreshIntervalSecs = 120; | 23 const int kDialRefreshIntervalSecs = 120; |
| 26 | 24 |
| 27 // We prune a device if it does not respond after this time. | 25 // We prune a device if it does not respond after this time. |
| 28 const int kDialExpirationSecs = 240; | 26 const int kDialExpirationSecs = 240; |
| 29 | 27 |
| 30 // The maximum number of devices retained at once in the registry. | 28 // The maximum number of devices retained at once in the registry. |
| 31 const size_t kDialMaxDevices = 256; | 29 const size_t kDialMaxDevices = 256; |
| 32 | 30 |
| 33 } // namespace | 31 } // namespace |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return true; | 154 return true; |
| 157 } | 155 } |
| 158 | 156 |
| 159 void DialDiscoverNowFunction::Work() { | 157 void DialDiscoverNowFunction::Work() { |
| 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 158 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 161 result_ = dial_->dial_registry()->DiscoverNow(); | 159 result_ = dial_->dial_registry()->DiscoverNow(); |
| 162 } | 160 } |
| 163 | 161 |
| 164 bool DialDiscoverNowFunction::Respond() { | 162 bool DialDiscoverNowFunction::Respond() { |
| 165 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 163 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 166 if (!result_) | |
| 167 error_ = kDialServiceError; | |
| 168 | |
| 169 SetResult(new base::FundamentalValue(result_)); | 164 SetResult(new base::FundamentalValue(result_)); |
| 170 return true; | 165 return true; |
| 171 } | 166 } |
| 172 | 167 |
| 173 } // namespace api | 168 } // namespace api |
| 174 | 169 |
| 175 } // namespace extensions | 170 } // namespace extensions |
| OLD | NEW |