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

Side by Side Diff: chrome/browser/chromeos/arc/arc_downloads_watcher_service.h

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Fix ui_arc_unittests Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/arc/arc_bridge_service.h" 13 #include "components/arc/arc_bridge_service.h"
14 #include "components/arc/arc_service.h" 14 #include "components/arc/arc_service.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 class FilePath; 18 class FilePath;
19 19
20 } // namespace base 20 } // namespace base
21 21
22 namespace arc { 22 namespace arc {
23 23
24 // Watches Downloads directory and registers newly created media files to 24 // Watches Downloads directory and registers newly created media files to
25 // Android MediaProvider. 25 // Android MediaProvider.
26 class ArcDownloadsWatcherService : public ArcService, 26 class ArcDownloadsWatcherService
27 public ArcBridgeService::Observer { 27 : public ArcService,
28 public ArcBridgeService::InstanceObserver<mojom::FileSystemInstance> {
28 public: 29 public:
29 explicit ArcDownloadsWatcherService(ArcBridgeService* bridge_service); 30 explicit ArcDownloadsWatcherService(ArcBridgeService* bridge_service);
30 ~ArcDownloadsWatcherService() override; 31 ~ArcDownloadsWatcherService() override;
31 32
32 // ArcBridgeService::Observer 33 // ArcBridgeService::InstanceObserver<mojom::FileSystemInstance>
33 void OnFileSystemInstanceReady() override; 34 void OnInstanceReady(mojom::FileSystemInstance*, uint32_t version) override;
34 void OnFileSystemInstanceClosed() override; 35 void OnInstanceClosed(mojom::FileSystemInstance*) override;
35 36
36 private: 37 private:
37 class DownloadsWatcher; 38 class DownloadsWatcher;
38 39
39 void StartWatchingDownloads(); 40 void StartWatchingDownloads();
40 void StopWatchingDownloads(); 41 void StopWatchingDownloads();
41 42
42 void OnDownloadsChanged(const std::vector<base::FilePath>& paths); 43 void OnDownloadsChanged(const std::vector<base::FilePath>& paths);
43 44
44 std::unique_ptr<DownloadsWatcher> watcher_; 45 std::unique_ptr<DownloadsWatcher> watcher_;
45 46
46 // Note: This should remain the last member so it'll be destroyed and 47 // Note: This should remain the last member so it'll be destroyed and
47 // invalidate the weak pointers before any other members are destroyed. 48 // invalidate the weak pointers before any other members are destroyed.
48 base::WeakPtrFactory<ArcDownloadsWatcherService> weak_ptr_factory_; 49 base::WeakPtrFactory<ArcDownloadsWatcherService> weak_ptr_factory_;
49 50
50 DISALLOW_COPY_AND_ASSIGN(ArcDownloadsWatcherService); 51 DISALLOW_COPY_AND_ASSIGN(ArcDownloadsWatcherService);
51 }; 52 };
52 53
53 } // namespace arc 54 } // namespace arc
54 55
55 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_ 56 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_DOWNLOADS_WATCHER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698