Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: device/media_transfer_protocol/media_transfer_protocol_manager.cc

Issue 2423793002: Remove usage of FOR_EACH_OBSERVER macro in device/ (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/hid/input_service_linux.cc ('k') | device/usb/usb_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "device/media_transfer_protocol/media_transfer_protocol_manager.h" 5 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 349
350 void OnStorageDetached(const std::string& storage_name) { 350 void OnStorageDetached(const std::string& storage_name) {
351 DCHECK(thread_checker_.CalledOnValidThread()); 351 DCHECK(thread_checker_.CalledOnValidThread());
352 if (storage_info_map_.erase(storage_name) == 0) { 352 if (storage_info_map_.erase(storage_name) == 0) {
353 // This can happen for a storage where 353 // This can happen for a storage where
354 // MediaTransferProtocolDaemonClient::GetStorageInfo() failed. 354 // MediaTransferProtocolDaemonClient::GetStorageInfo() failed.
355 // Return to avoid giving observers phantom detach events. 355 // Return to avoid giving observers phantom detach events.
356 return; 356 return;
357 } 357 }
358 FOR_EACH_OBSERVER(Observer, 358 for (auto& observer : observers_)
359 observers_, 359 observer.StorageChanged(false /* detach */, storage_name);
360 StorageChanged(false /* detach */, storage_name));
361 } 360 }
362 361
363 void OnStorageChanged(bool is_attach, const std::string& storage_name) { 362 void OnStorageChanged(bool is_attach, const std::string& storage_name) {
364 DCHECK(thread_checker_.CalledOnValidThread()); 363 DCHECK(thread_checker_.CalledOnValidThread());
365 DCHECK(mtp_client_); 364 DCHECK(mtp_client_);
366 if (is_attach) 365 if (is_attach)
367 OnStorageAttached(storage_name); 366 OnStorageAttached(storage_name);
368 else 367 else
369 OnStorageDetached(storage_name); 368 OnStorageDetached(storage_name);
370 } 369 }
(...skipping 20 matching lines...) Expand all
391 // After that, all incoming signals are either for new storage 390 // After that, all incoming signals are either for new storage
392 // attachments, which should not be in |storage_info_map_|, or for 391 // attachments, which should not be in |storage_info_map_|, or for
393 // storage detachments, which do not add to |storage_info_map_|. 392 // storage detachments, which do not add to |storage_info_map_|.
394 // Return to avoid giving observers phantom detach events. 393 // Return to avoid giving observers phantom detach events.
395 NOTREACHED(); 394 NOTREACHED();
396 return; 395 return;
397 } 396 }
398 397
399 // New storage. Add it and let the observers know. 398 // New storage. Add it and let the observers know.
400 storage_info_map_.insert(std::make_pair(storage_name, storage_info)); 399 storage_info_map_.insert(std::make_pair(storage_name, storage_info));
401 FOR_EACH_OBSERVER(Observer, 400 for (auto& observer : observers_)
402 observers_, 401 observer.StorageChanged(true /* is attach */, storage_name);
403 StorageChanged(true /* is attach */, storage_name));
404 } 402 }
405 403
406 void OnGetStorageInfoFromDevice(const MtpStorageInfo& storage_info) { 404 void OnGetStorageInfoFromDevice(const MtpStorageInfo& storage_info) {
407 get_storage_info_from_device_callbacks_.front().Run(storage_info, 405 get_storage_info_from_device_callbacks_.front().Run(storage_info,
408 false /* no error */); 406 false /* no error */);
409 get_storage_info_from_device_callbacks_.pop(); 407 get_storage_info_from_device_callbacks_.pop();
410 } 408 }
411 409
412 void OnGetStorageInfoFromDeviceError() { 410 void OnGetStorageInfoFromDeviceError() {
413 MtpStorageInfo info; 411 MtpStorageInfo info;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 DCHECK(!g_media_transfer_protocol_manager); 710 DCHECK(!g_media_transfer_protocol_manager);
713 711
714 g_media_transfer_protocol_manager = 712 g_media_transfer_protocol_manager =
715 new MediaTransferProtocolManagerImpl(task_runner); 713 new MediaTransferProtocolManagerImpl(task_runner);
716 VLOG(1) << "MediaTransferProtocolManager initialized"; 714 VLOG(1) << "MediaTransferProtocolManager initialized";
717 715
718 return g_media_transfer_protocol_manager; 716 return g_media_transfer_protocol_manager;
719 } 717 }
720 718
721 } // namespace device 719 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/input_service_linux.cc ('k') | device/usb/usb_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698