| 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 // This used to do a lot of TLS-based management of multiple Directory objects. | 5 // This used to do a lot of TLS-based management of multiple Directory objects. |
| 6 // We now can access Directory objects from any thread for general purpose | 6 // We now can access Directory objects from any thread for general purpose |
| 7 // operations and we only ever have one Directory, so this class isn't doing | 7 // operations and we only ever have one Directory, so this class isn't doing |
| 8 // anything too fancy besides keeping calling and access conventions the same | 8 // anything too fancy besides keeping calling and access conventions the same |
| 9 // for now. | 9 // for now. |
| 10 // TODO(timsteele): We can probably nuke this entire class and use raw | 10 // TODO(timsteele): We can probably nuke this entire class and use raw |
| 11 // Directory objects everywhere. | 11 // Directory objects everywhere. |
| 12 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ | 12 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ |
| 13 #define CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ | 13 #define CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/atomicops.h" | 18 #include "base/atomicops.h" |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
| 21 #include "base/lock.h" | 21 #include "base/lock.h" |
| 22 #include "chrome/browser/sync/syncable/dir_open_result.h" | 22 #include "chrome/browser/sync/syncable/dir_open_result.h" |
| 23 #include "chrome/browser/sync/syncable/path_name_cmp.h" | 23 #include "chrome/browser/sync/syncable/path_name_cmp.h" |
| 24 #include "chrome/browser/sync/syncable/syncable.h" | 24 #include "chrome/browser/sync/syncable/syncable.h" |
| 25 #include "chrome/browser/sync/util/cryptographer.h" |
| 25 #include "chrome/browser/sync/util/sync_types.h" | 26 #include "chrome/browser/sync/util/sync_types.h" |
| 26 #include "chrome/common/deprecated/event_sys.h" | 27 #include "chrome/common/deprecated/event_sys.h" |
| 27 | 28 |
| 28 namespace sync_api { class BaseTransaction; } | 29 namespace sync_api { class BaseTransaction; } |
| 29 | 30 |
| 30 namespace syncable { | 31 namespace syncable { |
| 31 | 32 |
| 32 struct DirectoryManagerEvent { | 33 struct DirectoryManagerEvent { |
| 33 enum { | 34 enum { |
| 34 OPEN_FAILED, | 35 OPEN_FAILED, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 70 |
| 70 // Should be called at App exit. | 71 // Should be called at App exit. |
| 71 void FinalSaveChangesForAll(); | 72 void FinalSaveChangesForAll(); |
| 72 | 73 |
| 73 // Gets the list of currently open directory names. | 74 // Gets the list of currently open directory names. |
| 74 typedef std::vector<std::string> DirNames; | 75 typedef std::vector<std::string> DirNames; |
| 75 void GetOpenDirectories(DirNames* result); | 76 void GetOpenDirectories(DirNames* result); |
| 76 | 77 |
| 77 Channel* channel() const { return channel_; } | 78 Channel* channel() const { return channel_; } |
| 78 | 79 |
| 80 browser_sync::Cryptographer* cryptographer() const { |
| 81 return cryptographer_.get(); |
| 82 } |
| 83 |
| 79 protected: | 84 protected: |
| 80 DirOpenResult OpenImpl(const std::string& name, const FilePath& path, | 85 DirOpenResult OpenImpl(const std::string& name, const FilePath& path, |
| 81 bool* was_open); | 86 bool* was_open); |
| 82 | 87 |
| 83 // Helpers for friend class ScopedDirLookup: | 88 // Helpers for friend class ScopedDirLookup: |
| 84 friend class ScopedDirLookup; | 89 friend class ScopedDirLookup; |
| 85 | 90 |
| 86 const FilePath root_path_; | 91 const FilePath root_path_; |
| 87 | 92 |
| 88 // protects managed_directory_ | 93 // protects managed_directory_ |
| 89 Lock lock_; | 94 Lock lock_; |
| 90 Directory* managed_directory_; | 95 Directory* managed_directory_; |
| 91 | 96 |
| 92 Channel* const channel_; | 97 Channel* const channel_; |
| 93 | 98 |
| 99 scoped_ptr<browser_sync::Cryptographer> cryptographer_; |
| 100 |
| 94 private: | 101 private: |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(DirectoryManager); | 102 DISALLOW_COPY_AND_ASSIGN(DirectoryManager); |
| 97 }; | 103 }; |
| 98 | 104 |
| 99 | 105 |
| 100 class ScopedDirLookup { | 106 class ScopedDirLookup { |
| 101 public: | 107 public: |
| 102 ScopedDirLookup(DirectoryManager* dirman, const std::string& name); | 108 ScopedDirLookup(DirectoryManager* dirman, const std::string& name); |
| 103 ~ScopedDirLookup(); | 109 ~ScopedDirLookup(); |
| 104 | 110 |
| 105 inline bool good() { | 111 inline bool good() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 117 bool good_; | 123 bool good_; |
| 118 // Ensure that the programmer checks good before using the ScopedDirLookup. | 124 // Ensure that the programmer checks good before using the ScopedDirLookup. |
| 119 // This member should can be removed if it ever shows up in profiling | 125 // This member should can be removed if it ever shows up in profiling |
| 120 bool good_checked_; | 126 bool good_checked_; |
| 121 DirectoryManager* const dirman_; | 127 DirectoryManager* const dirman_; |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 } // namespace syncable | 130 } // namespace syncable |
| 125 | 131 |
| 126 #endif // CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ | 132 #endif // CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_MANAGER_H_ |
| OLD | NEW |