| 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/local_discovery/storage/privet_volume_lister.h" | 5 #include "chrome/browser/local_discovery/storage/privet_volume_lister.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" | 10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 PrivetVolumeLister::PrivetVolumeLister(const ResultCallback& callback) | 62 PrivetVolumeLister::PrivetVolumeLister(const ResultCallback& callback) |
| 63 : callback_(callback), weak_factory_(this) { | 63 : callback_(callback), weak_factory_(this) { |
| 64 } | 64 } |
| 65 | 65 |
| 66 PrivetVolumeLister::~PrivetVolumeLister() { | 66 PrivetVolumeLister::~PrivetVolumeLister() { |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PrivetVolumeLister::Start() { | 69 void PrivetVolumeLister::Start() { |
| 70 #if defined(ENABLE_SERVICE_DISCOVERY) | 70 #if defined(ENABLE_SERVICE_DISCOVERY) |
| 71 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); | 71 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); |
| 72 privet_lister_.reset(new PrivetDeviceListerImpl(service_discovery_client_, | 72 privet_lister_.reset( |
| 73 this)); | 73 new PrivetDeviceListerImpl(service_discovery_client_.get(), this)); |
| 74 privet_lister_->Start(); | 74 privet_lister_->Start(); |
| 75 privet_lister_->DiscoverNewDevices(false); | 75 privet_lister_->DiscoverNewDevices(false); |
| 76 base::MessageLoop::current()->PostDelayedTask( | 76 base::MessageLoop::current()->PostDelayedTask( |
| 77 FROM_HERE, | 77 FROM_HERE, |
| 78 base::Bind(&PrivetVolumeLister::FinishSearch, | 78 base::Bind(&PrivetVolumeLister::FinishSearch, |
| 79 weak_factory_.GetWeakPtr()), | 79 weak_factory_.GetWeakPtr()), |
| 80 base::TimeDelta::FromMilliseconds(kVolumeSearchDurationMs)); | 80 base::TimeDelta::FromMilliseconds(kVolumeSearchDurationMs)); |
| 81 #else | 81 #else |
| 82 callback_.Run(std::vector<VolumeInfo>()); | 82 callback_.Run(std::vector<VolumeInfo>()); |
| 83 #endif | 83 #endif |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 | 114 |
| 115 void PrivetVolumeLister::FinishSearch() { | 115 void PrivetVolumeLister::FinishSearch() { |
| 116 privet_lister_.reset(); | 116 privet_lister_.reset(); |
| 117 service_discovery_client_ = NULL; | 117 service_discovery_client_ = NULL; |
| 118 available_volumes_.swap(canonical_volume_list_); | 118 available_volumes_.swap(canonical_volume_list_); |
| 119 callback_.Run(canonical_volume_list_); | 119 callback_.Run(canonical_volume_list_); |
| 120 } | 120 } |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 } // namespace local_discovery | 123 } // namespace local_discovery |
| OLD | NEW |