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

Side by Side Diff: chrome/browser/media_galleries/media_scan_manager.cc

Issue 204703002: Rename NOTIFICATION_EXTENSION_UNLOADED to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe upload wont do something bizarre this time Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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/media_galleries/media_scan_manager.h" 5 #include "chrome/browser/media_galleries/media_scan_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 scans_for_profile->second.observer->OnScanFinished(extension->id(), 365 scans_for_profile->second.observer->OnScanFinished(extension->id(),
366 gallery_count, 366 gallery_count,
367 file_counts); 367 file_counts);
368 return; 368 return;
369 } 369 }
370 370
371 // On first scan for the |profile|, register to listen for extension unload. 371 // On first scan for the |profile|, register to listen for extension unload.
372 if (scanning_extensions->empty()) { 372 if (scanning_extensions->empty()) {
373 registrar_.Add( 373 registrar_.Add(
374 this, 374 this,
375 chrome::NOTIFICATION_EXTENSION_UNLOADED, 375 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
376 content::Source<Profile>(profile)); 376 content::Source<Profile>(profile));
377 } 377 }
378 378
379 scanning_extensions->insert(extension->id()); 379 scanning_extensions->insert(extension->id());
380 scans_for_profile->second.observer->OnScanStarted(extension->id()); 380 scans_for_profile->second.observer->OnScanStarted(extension->id());
381 381
382 if (folder_finder_) 382 if (folder_finder_)
383 return; 383 return;
384 384
385 MediaFolderFinder::MediaFolderFinderResultsCallback callback = 385 MediaFolderFinder::MediaFolderFinderResultsCallback callback =
(...skipping 18 matching lines...) Expand all
404 !scans_for_profile->second.scanning_extensions.erase(extension->id())) { 404 !scans_for_profile->second.scanning_extensions.erase(extension->id())) {
405 return; 405 return;
406 } 406 }
407 407
408 scans_for_profile->second.observer->OnScanCancelled(extension->id()); 408 scans_for_profile->second.observer->OnScanCancelled(extension->id());
409 409
410 // No more scanning extensions for |profile|, so stop listening for unloads. 410 // No more scanning extensions for |profile|, so stop listening for unloads.
411 if (scans_for_profile->second.scanning_extensions.empty()) { 411 if (scans_for_profile->second.scanning_extensions.empty()) {
412 registrar_.Remove( 412 registrar_.Remove(
413 this, 413 this,
414 chrome::NOTIFICATION_EXTENSION_UNLOADED, 414 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
415 content::Source<Profile>(profile)); 415 content::Source<Profile>(profile));
416 } 416 }
417 417
418 if (!ScanInProgress()) { 418 if (!ScanInProgress()) {
419 folder_finder_.reset(); 419 folder_finder_.reset();
420 DCHECK(!scan_start_time_.is_null()); 420 DCHECK(!scan_start_time_.is_null());
421 UMA_HISTOGRAM_LONG_TIMES("MediaGalleries.ScanCancelTime", 421 UMA_HISTOGRAM_LONG_TIMES("MediaGalleries.ScanCancelTime",
422 base::Time::Now() - scan_start_time_); 422 base::Time::Now() - scan_start_time_);
423 scan_start_time_ = base::Time(); 423 scan_start_time_ = base::Time();
424 } 424 }
425 } 425 }
426 426
427 void MediaScanManager::SetMediaFolderFinderFactory( 427 void MediaScanManager::SetMediaFolderFinderFactory(
428 const MediaFolderFinderFactory& factory) { 428 const MediaFolderFinderFactory& factory) {
429 testing_folder_finder_factory_ = factory; 429 testing_folder_finder_factory_ = factory;
430 } 430 }
431 431
432 MediaScanManager::ScanObservers::ScanObservers() : observer(NULL) {} 432 MediaScanManager::ScanObservers::ScanObservers() : observer(NULL) {}
433 MediaScanManager::ScanObservers::~ScanObservers() {} 433 MediaScanManager::ScanObservers::~ScanObservers() {}
434 434
435 void MediaScanManager::Observe( 435 void MediaScanManager::Observe(
436 int type, const content::NotificationSource& source, 436 int type, const content::NotificationSource& source,
437 const content::NotificationDetails& details) { 437 const content::NotificationDetails& details) {
438 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 438 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
439 switch (type) { 439 switch (type) {
440 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 440 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
441 Profile* profile = content::Source<Profile>(source).ptr(); 441 Profile* profile = content::Source<Profile>(source).ptr();
442 extensions::Extension* extension = const_cast<extensions::Extension*>( 442 extensions::Extension* extension = const_cast<extensions::Extension*>(
443 content::Details<extensions::UnloadedExtensionInfo>( 443 content::Details<extensions::UnloadedExtensionInfo>(
444 details)->extension); 444 details)->extension);
445 DCHECK(extension); 445 DCHECK(extension);
446 CancelScan(profile, extension); 446 CancelScan(profile, extension);
447 break; 447 break;
448 } 448 }
449 default: 449 default:
450 NOTREACHED(); 450 NOTREACHED();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 gallery_count, 525 gallery_count,
526 file_counts); 526 file_counts);
527 } 527 }
528 } 528 }
529 scanning_extensions->clear(); 529 scanning_extensions->clear();
530 preferences->SetLastScanCompletionTime(base::Time::Now()); 530 preferences->SetLastScanCompletionTime(base::Time::Now());
531 } 531 }
532 registrar_.RemoveAll(); 532 registrar_.RemoveAll();
533 folder_finder_.reset(); 533 folder_finder_.reset();
534 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_scan_manager.h ('k') | chrome/browser/notifications/notification_system_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698