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

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

Issue 2654303002: Always call StorageMonitor::RemoveObserver in ~MediaFileSystemRegistry. (Closed)
Patch Set: add include Created 3 years, 11 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 | « no previous file | chrome/browser/media_galleries/gallery_watch_manager_unittest.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 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/gallery_watch_manager.h" 5 #include "chrome/browser/media_galleries/gallery_watch_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h" 17 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h"
17 #include "chrome/browser/media_galleries/media_file_system_registry.h" 18 #include "chrome/browser/media_galleries/media_file_system_registry.h"
18 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 19 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "components/keyed_service/content/browser_context_keyed_service_shutdow n_notifier_factory.h" 21 #include "components/keyed_service/content/browser_context_keyed_service_shutdow n_notifier_factory.h"
21 #include "components/storage_monitor/storage_monitor.h" 22 #include "components/storage_monitor/storage_monitor.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 GalleryWatchManager::GalleryWatchManager() 177 GalleryWatchManager::GalleryWatchManager()
177 : storage_monitor_observed_(false), weak_factory_(this) { 178 : storage_monitor_observed_(false), weak_factory_(this) {
178 DCHECK_CURRENTLY_ON(BrowserThread::UI); 179 DCHECK_CURRENTLY_ON(BrowserThread::UI);
179 watch_manager_.reset(new FileWatchManager(base::Bind( 180 watch_manager_.reset(new FileWatchManager(base::Bind(
180 &GalleryWatchManager::OnFilePathChanged, weak_factory_.GetWeakPtr()))); 181 &GalleryWatchManager::OnFilePathChanged, weak_factory_.GetWeakPtr())));
181 } 182 }
182 183
183 GalleryWatchManager::~GalleryWatchManager() { 184 GalleryWatchManager::~GalleryWatchManager() {
184 weak_factory_.InvalidateWeakPtrs(); 185 weak_factory_.InvalidateWeakPtrs();
185 186
186 if (storage_monitor_observed_ && 187 if (storage_monitor_observed_) {
187 storage_monitor::StorageMonitor::GetInstance()) { 188 DCHECK(storage_monitor::StorageMonitor::GetInstance());
188 storage_monitor::StorageMonitor::GetInstance()->RemoveObserver(this); 189 storage_monitor::StorageMonitor::GetInstance()->RemoveObserver(this);
189 } 190 }
190 191
191 BrowserThread::DeleteSoon( 192 BrowserThread::DeleteSoon(
192 BrowserThread::FILE, FROM_HERE, watch_manager_.release()); 193 BrowserThread::FILE, FROM_HERE, watch_manager_.release());
193 } 194 }
194 195
195 void GalleryWatchManager::AddObserver(BrowserContext* browser_context, 196 void GalleryWatchManager::AddObserver(BrowserContext* browser_context,
196 GalleryWatchManagerObserver* observer) { 197 GalleryWatchManagerObserver* observer) {
197 DCHECK(browser_context); 198 DCHECK(browser_context);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 DeactivateFileWatch(owner, it->second); 494 DeactivateFileWatch(owner, it->second);
494 // Post increment moves iterator to next element while deleting current. 495 // Post increment moves iterator to next element while deleting current.
495 watches_.erase(it++); 496 watches_.erase(it++);
496 observers_[preferences->profile()]->OnGalleryWatchDropped( 497 observers_[preferences->profile()]->OnGalleryWatchDropped(
497 owner.extension_id, owner.gallery_id); 498 owner.extension_id, owner.gallery_id);
498 } else { 499 } else {
499 ++it; 500 ++it;
500 } 501 }
501 } 502 }
502 } 503 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_galleries/gallery_watch_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698