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