| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" | 10 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 class TestDelegate : public PepperDeviceEnumerationHostHelper::Delegate { | 27 class TestDelegate : public PepperDeviceEnumerationHostHelper::Delegate { |
| 28 public: | 28 public: |
| 29 TestDelegate() : last_used_id_(0) {} | 29 TestDelegate() : last_used_id_(0) {} |
| 30 | 30 |
| 31 virtual ~TestDelegate() { CHECK(callbacks_.empty()); } | 31 virtual ~TestDelegate() { CHECK(callbacks_.empty()); } |
| 32 | 32 |
| 33 virtual int EnumerateDevices(PP_DeviceType_Dev /* type */, | 33 virtual int EnumerateDevices(PP_DeviceType_Dev /* type */, |
| 34 const GURL& /* document_url */, | 34 const GURL& /* document_url */, |
| 35 const EnumerateDevicesCallback& callback) | 35 const EnumerateDevicesCallback& callback) |
| 36 OVERRIDE { | 36 override { |
| 37 last_used_id_++; | 37 last_used_id_++; |
| 38 callbacks_[last_used_id_] = callback; | 38 callbacks_[last_used_id_] = callback; |
| 39 return last_used_id_; | 39 return last_used_id_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void StopEnumerateDevices(int request_id) OVERRIDE { | 42 virtual void StopEnumerateDevices(int request_id) override { |
| 43 std::map<int, EnumerateDevicesCallback>::iterator iter = | 43 std::map<int, EnumerateDevicesCallback>::iterator iter = |
| 44 callbacks_.find(request_id); | 44 callbacks_.find(request_id); |
| 45 CHECK(iter != callbacks_.end()); | 45 CHECK(iter != callbacks_.end()); |
| 46 callbacks_.erase(iter); | 46 callbacks_.erase(iter); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Returns false if |request_id| is not found. | 49 // Returns false if |request_id| is not found. |
| 50 bool SimulateEnumerateResult( | 50 bool SimulateEnumerateResult( |
| 51 int request_id, | 51 int request_id, |
| 52 const std::vector<ppapi::DeviceRefData>& devices) { | 52 const std::vector<ppapi::DeviceRefData>& devices) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ppapi::host::HostMessageContext context(call_params); | 225 ppapi::host::HostMessageContext context(call_params); |
| 226 int32_t result = PP_ERROR_FAILED; | 226 int32_t result = PP_ERROR_FAILED; |
| 227 ASSERT_TRUE( | 227 ASSERT_TRUE( |
| 228 device_enumeration_.HandleResourceMessage(msg, &context, &result)); | 228 device_enumeration_.HandleResourceMessage(msg, &context, &result)); |
| 229 EXPECT_EQ(PP_OK, result); | 229 EXPECT_EQ(PP_OK, result); |
| 230 | 230 |
| 231 EXPECT_EQ(0U, delegate_.GetRegisteredCallbackCount()); | 231 EXPECT_EQ(0U, delegate_.GetRegisteredCallbackCount()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace content | 234 } // namespace content |
| OLD | NEW |