OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/extensions/file_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 89 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
90 DCHECK(file_watchers_.empty()); | 90 DCHECK(file_watchers_.empty()); |
91 STLDeleteValues(&file_watchers_); | 91 STLDeleteValues(&file_watchers_); |
92 | 92 |
93 if (!profile_) { | 93 if (!profile_) { |
94 NOTREACHED(); | 94 NOTREACHED(); |
95 return; | 95 return; |
96 } | 96 } |
97 profile_ = NULL; | 97 profile_ = NULL; |
98 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | |
99 return; | |
100 chromeos::MountLibrary* lib = | 98 chromeos::MountLibrary* lib = |
101 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 99 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
102 lib->RemoveObserver(this); | 100 lib->RemoveObserver(this); |
103 } | 101 } |
104 | 102 |
105 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { | 103 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { |
106 if (!profile_) { | 104 if (!profile_) { |
107 NOTREACHED(); | 105 NOTREACHED(); |
108 return; | 106 return; |
109 } | 107 } |
110 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | |
111 return; | |
112 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 108 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
113 chromeos::MountLibrary* lib = | 109 chromeos::MountLibrary* lib = |
114 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 110 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
115 lib->RemoveObserver(this); | 111 lib->RemoveObserver(this); |
116 lib->AddObserver(this); | 112 lib->AddObserver(this); |
117 lib->RequestMountInfoRefresh(); | 113 lib->RequestMountInfoRefresh(); |
118 } | 114 } |
119 } | 115 } |
120 | 116 |
121 // File watch setup routines. | 117 // File watch setup routines. |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 516 |
521 const FilePath& | 517 const FilePath& |
522 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 518 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
523 return virtual_path; | 519 return virtual_path; |
524 } | 520 } |
525 | 521 |
526 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch | 522 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch |
527 (const FilePath& path, FileWatcherDelegate* delegate) { | 523 (const FilePath& path, FileWatcherDelegate* delegate) { |
528 return file_watcher->Watch(path, delegate); | 524 return file_watcher->Watch(path, delegate); |
529 } | 525 } |
OLD | NEW |