| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/devtools/device/android_device_manager.h" | 5 #include "chrome/browser/devtools/device/android_device_manager.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 const DevicesCallback& callback, | 480 const DevicesCallback& callback, |
| 481 DeviceDescriptors* descriptors_raw) { | 481 DeviceDescriptors* descriptors_raw) { |
| 482 scoped_ptr<DeviceDescriptors> descriptors(descriptors_raw); | 482 scoped_ptr<DeviceDescriptors> descriptors(descriptors_raw); |
| 483 Devices response; | 483 Devices response; |
| 484 DeviceWeakMap new_devices; | 484 DeviceWeakMap new_devices; |
| 485 for (DeviceDescriptors::const_iterator it = descriptors->begin(); | 485 for (DeviceDescriptors::const_iterator it = descriptors->begin(); |
| 486 it != descriptors->end(); | 486 it != descriptors->end(); |
| 487 ++it) { | 487 ++it) { |
| 488 DeviceWeakMap::iterator found = devices_.find(it->serial); | 488 DeviceWeakMap::iterator found = devices_.find(it->serial); |
| 489 scoped_refptr<Device> device; | 489 scoped_refptr<Device> device; |
| 490 if (found == devices_.end() || !found->second | 490 if (found == devices_.end() || !found->second || |
| 491 || found->second->provider_ != it->provider) { | 491 found->second->provider_.get() != it->provider.get()) { |
| 492 device = new Device(handler_thread_->message_loop(), | 492 device = new Device(handler_thread_->message_loop(), |
| 493 it->provider, it->serial); | 493 it->provider, it->serial); |
| 494 } else { | 494 } else { |
| 495 device = found->second.get(); | 495 device = found->second.get(); |
| 496 } | 496 } |
| 497 response.push_back(device); | 497 response.push_back(device); |
| 498 new_devices[it->serial] = device->weak_factory_.GetWeakPtr(); | 498 new_devices[it->serial] = device->weak_factory_.GetWeakPtr(); |
| 499 } | 499 } |
| 500 devices_.swap(new_devices); | 500 devices_.swap(new_devices); |
| 501 callback.Run(response); | 501 callback.Run(response); |
| 502 } | 502 } |
| OLD | NEW |