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

Side by Side Diff: chrome/browser/media_galleries/fileapi/iapps_data_provider.h

Issue 2518053002: Always delete media galleries FilePathWatchers on the FILE thread. (Closed)
Patch Set: fix build error Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_path_watcher.h" 15 #include "base/files/file_path_watcher.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "chrome/browser/media_galleries/fileapi/file_path_watcher_util.h"
18 19
19 namespace iapps { 20 namespace iapps {
20 21
21 // This class is the holder for iTunes parsed data. Given a path to the iTunes 22 // This class is the holder for iTunes parsed data. Given a path to the iTunes
22 // library XML file it will read it in, parse the data, and provide convenient 23 // library XML file it will read it in, parse the data, and provide convenient
23 // methods to access it. When the file changes, it will update the data. 24 // methods to access it. When the file changes, it will update the data.
24 // It is not thread safe, but can be run on any thread with IO access. 25 // It is not thread safe, but can be run on any thread with IO access.
25 class IAppsDataProvider { 26 class IAppsDataProvider {
26 public: 27 public:
27 typedef base::Callback<void(bool)> ReadyCallback; 28 typedef base::Callback<void(bool)> ReadyCallback;
(...skipping 18 matching lines...) Expand all
46 // should be called when parsing has finished. 47 // should be called when parsing has finished.
47 virtual void DoParseLibrary(const base::FilePath& library_path, 48 virtual void DoParseLibrary(const base::FilePath& library_path,
48 const ReadyCallback& ready_callback) = 0; 49 const ReadyCallback& ready_callback) = 0;
49 50
50 // Called when |library_path_| has changed. Virtual for testing. 51 // Called when |library_path_| has changed. Virtual for testing.
51 virtual void OnLibraryChanged(const base::FilePath& path, bool error); 52 virtual void OnLibraryChanged(const base::FilePath& path, bool error);
52 53
53 private: 54 private:
54 // Called when the FilePathWatcher for |library_path_| has tried to add an 55 // Called when the FilePathWatcher for |library_path_| has tried to add an
55 // watch. 56 // watch.
56 void OnLibraryWatchStarted( 57 void OnLibraryWatchStarted(MediaFilePathWatcherUniquePtr library_watcher);
57 std::unique_ptr<base::FilePathWatcher> library_watcher);
58 58
59 // Path to the library XML file. 59 // Path to the library XML file.
60 const base::FilePath library_path_; 60 const base::FilePath library_path_;
61 61
62 // True if the data needs to be refreshed from disk. 62 // True if the data needs to be refreshed from disk.
63 bool needs_refresh_; 63 bool needs_refresh_;
64 64
65 // True if |library_| contains valid data. False at construction and if 65 // True if |library_| contains valid data. False at construction and if
66 // reading or parsing the XML file fails. 66 // reading or parsing the XML file fails.
67 bool is_valid_; 67 bool is_valid_;
68 68
69 // A watcher on the library xml file. 69 // A watcher on the library xml file.
70 std::unique_ptr<base::FilePathWatcher> library_watcher_; 70 MediaFilePathWatcherUniquePtr library_watcher_;
71 71
72 base::WeakPtrFactory<IAppsDataProvider> weak_factory_; 72 base::WeakPtrFactory<IAppsDataProvider> weak_factory_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(IAppsDataProvider); 74 DISALLOW_COPY_AND_ASSIGN(IAppsDataProvider);
75 }; 75 };
76 76
77 } // namespace iapps 77 } // namespace iapps
78 78
79 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_ 79 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IAPPS_DATA_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698