OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/sync/syncable/directory_manager.h" | 5 #include "chrome/browser/sync/syncable/directory_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 AutoLock lock(lock_); | 47 AutoLock lock(lock_); |
48 DCHECK_EQ(managed_directory_, static_cast<Directory*>(NULL)) | 48 DCHECK_EQ(managed_directory_, static_cast<Directory*>(NULL)) |
49 << "Dir " << managed_directory_->name() << " not closed!"; | 49 << "Dir " << managed_directory_->name() << " not closed!"; |
50 delete channel_; | 50 delete channel_; |
51 } | 51 } |
52 | 52 |
53 bool DirectoryManager::Open(const std::string& name) { | 53 bool DirectoryManager::Open(const std::string& name) { |
54 bool was_open = false; | 54 bool was_open = false; |
55 const DirOpenResult result = OpenImpl(name, | 55 const DirOpenResult result = OpenImpl(name, |
56 GetSyncDataDatabasePath(), &was_open); | 56 GetSyncDataDatabasePath(), &was_open); |
57 if (!was_open) { | |
58 DirectoryManagerEvent event; | |
59 event.dirname = name; | |
60 if (syncable::OPENED == result) { | |
61 event.what_happened = DirectoryManagerEvent::OPENED; | |
62 } else { | |
63 event.what_happened = DirectoryManagerEvent::OPEN_FAILED; | |
64 event.error = result; | |
65 } | |
66 channel_->NotifyListeners(event); | |
67 } | |
68 return syncable::OPENED == result; | 57 return syncable::OPENED == result; |
69 } | 58 } |
70 | 59 |
71 // Opens a directory. Returns false on error. | 60 // Opens a directory. Returns false on error. |
72 DirOpenResult DirectoryManager::OpenImpl(const std::string& name, | 61 DirOpenResult DirectoryManager::OpenImpl(const std::string& name, |
73 const FilePath& path, | 62 const FilePath& path, |
74 bool* was_open) { | 63 bool* was_open) { |
75 bool opened = false; | 64 bool opened = false; |
76 { | 65 { |
77 AutoLock lock(lock_); | 66 AutoLock lock(lock_); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return dir_; | 138 return dir_; |
150 } | 139 } |
151 | 140 |
152 ScopedDirLookup::operator Directory* () const { | 141 ScopedDirLookup::operator Directory* () const { |
153 CHECK(good_checked_); | 142 CHECK(good_checked_); |
154 DCHECK(good_); | 143 DCHECK(good_); |
155 return dir_; | 144 return dir_; |
156 } | 145 } |
157 | 146 |
158 } // namespace syncable | 147 } // namespace syncable |
OLD | NEW |