| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 class TestDelegate : public PepperDeviceEnumerationHostHelper::Delegate, | 48 class TestDelegate : public PepperDeviceEnumerationHostHelper::Delegate, |
| 49 public base::SupportsWeakPtr<TestDelegate> { | 49 public base::SupportsWeakPtr<TestDelegate> { |
| 50 public: | 50 public: |
| 51 TestDelegate() : last_used_id_(0) {} | 51 TestDelegate() : last_used_id_(0) {} |
| 52 | 52 |
| 53 ~TestDelegate() override { CHECK(monitoring_callbacks_.empty()); } | 53 ~TestDelegate() override { CHECK(monitoring_callbacks_.empty()); } |
| 54 | 54 |
| 55 void EnumerateDevices(PP_DeviceType_Dev /* type */, | 55 void EnumerateDevices(PP_DeviceType_Dev /* type */, |
| 56 const GURL& /* document_url */, | |
| 57 const DevicesCallback& callback) override { | 56 const DevicesCallback& callback) override { |
| 58 callback.Run(TestEnumerationData()); | 57 callback.Run(TestEnumerationData()); |
| 59 } | 58 } |
| 60 | 59 |
| 61 uint32_t StartMonitoringDevices(PP_DeviceType_Dev /* type */, | 60 uint32_t StartMonitoringDevices(PP_DeviceType_Dev /* type */, |
| 62 const GURL& /* document_url */, | |
| 63 const DevicesCallback& callback) override { | 61 const DevicesCallback& callback) override { |
| 64 last_used_id_++; | 62 last_used_id_++; |
| 65 monitoring_callbacks_[last_used_id_] = callback; | 63 monitoring_callbacks_[last_used_id_] = callback; |
| 66 return last_used_id_; | 64 return last_used_id_; |
| 67 } | 65 } |
| 68 | 66 |
| 69 void StopMonitoringDevices(PP_DeviceType_Dev /* type */, | 67 void StopMonitoringDevices(PP_DeviceType_Dev /* type */, |
| 70 uint32_t subscription_id) override { | 68 uint32_t subscription_id) override { |
| 71 auto iter = monitoring_callbacks_.find(subscription_id); | 69 auto iter = monitoring_callbacks_.find(subscription_id); |
| 72 CHECK(iter != monitoring_callbacks_.end()); | 70 CHECK(iter != monitoring_callbacks_.end()); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 ppapi::host::HostMessageContext context(call_params); | 234 ppapi::host::HostMessageContext context(call_params); |
| 237 int32_t result = PP_ERROR_FAILED; | 235 int32_t result = PP_ERROR_FAILED; |
| 238 ASSERT_TRUE( | 236 ASSERT_TRUE( |
| 239 device_enumeration_.HandleResourceMessage(msg, &context, &result)); | 237 device_enumeration_.HandleResourceMessage(msg, &context, &result)); |
| 240 EXPECT_EQ(PP_OK, result); | 238 EXPECT_EQ(PP_OK, result); |
| 241 | 239 |
| 242 EXPECT_EQ(0U, delegate_.GetRegisteredCallbackCount()); | 240 EXPECT_EQ(0U, delegate_.GetRegisteredCallbackCount()); |
| 243 } | 241 } |
| 244 | 242 |
| 245 } // namespace content | 243 } // namespace content |
| OLD | NEW |