| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ | 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ |
| 6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ | 6 #define WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "webkit/fileapi/file_system_url.h" | 14 #include "webkit/fileapi/file_system_url.h" |
| 15 | 15 |
| 16 namespace fileapi { | 16 namespace fileapi { |
| 17 | 17 |
| 18 // Represents local file sync status. | 18 // Represents local file sync status. |
| 19 // This class is supposed to run only on IO thread. | 19 // This class is supposed to run only on IO thread. |
| 20 // | 20 // |
| 21 // This class manages two important synchronization flags: writing (counter) | 21 // This class manages two important synchronization flags: writing (counter) |
| 22 // and syncing (flag). Writing counter keeps track of which URL is in | 22 // and syncing (flag). Writing counter keeps track of which URL is in |
| 23 // writing and syncing flag indicates which URL is in syncing. | 23 // writing and syncing flag indicates which URL is in syncing. |
| 24 // | 24 // |
| 25 // An invariant of this class is: no FileSystem objects should be both | 25 // An invariant of this class is: no FileSystem objects should be both |
| 26 // in syncing_ and writing_ status, i.e. trying to increment writing | 26 // in syncing_ and writing_ status, i.e. trying to increment writing |
| 27 // while the target url is in syncing must fail and vice versa. | 27 // while the target url is in syncing must fail and vice versa. |
| 28 class FILEAPI_EXPORT LocalFileSyncStatus : public base::NonThreadSafe { | 28 class WEBKIT_STORAGE_EXPORT LocalFileSyncStatus : public base::NonThreadSafe { |
| 29 public: | 29 public: |
| 30 LocalFileSyncStatus(); | 30 LocalFileSyncStatus(); |
| 31 ~LocalFileSyncStatus(); | 31 ~LocalFileSyncStatus(); |
| 32 | 32 |
| 33 // Tries to increment writing counter for |url|. | 33 // Tries to increment writing counter for |url|. |
| 34 // This fails if the target |url| is in syncing. | 34 // This fails if the target |url| is in syncing. |
| 35 bool TryIncrementWriting(const FileSystemURL& url); | 35 bool TryIncrementWriting(const FileSystemURL& url); |
| 36 | 36 |
| 37 // Decrement writing counter for |url|. | 37 // Decrement writing counter for |url|. |
| 38 void DecrementWriting(const FileSystemURL& url); | 38 void DecrementWriting(const FileSystemURL& url); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 | 63 |
| 64 // If this flag is set sync process is running on the file. | 64 // If this flag is set sync process is running on the file. |
| 65 URLSet syncing_; | 65 URLSet syncing_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncStatus); | 67 DISALLOW_COPY_AND_ASSIGN(LocalFileSyncStatus); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace fileapi | 70 } // namespace fileapi |
| 71 | 71 |
| 72 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ | 72 #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ |
| OLD | NEW |