OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_FIND_ENTRY_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_FIND_ENTRY_DELEGATE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/platform_file.h" |
| 11 |
| 12 class FilePath; |
| 13 |
| 14 namespace gdata { |
| 15 |
| 16 class GDataEntry; |
| 17 |
| 18 // Used to get result of file search. Please note that |file| is a live |
| 19 // object provided to this callback under lock. It must not be used outside |
| 20 // of the callback method. This callback can be invoked on different thread |
| 21 // than one that started the request. |
| 22 typedef base::Callback<void(base::PlatformFileError error, |
| 23 const FilePath& directory_path, |
| 24 GDataEntry* entry)> |
| 25 FindEntryCallback; |
| 26 |
| 27 // Delegate class used to deal with results synchronous read-only search |
| 28 // over virtual file system. |
| 29 class FindEntryDelegate { |
| 30 public: |
| 31 virtual ~FindEntryDelegate(); |
| 32 |
| 33 // Called when FindEntryByPathSync() completes search. |
| 34 virtual void OnDone(base::PlatformFileError error, |
| 35 const FilePath& directory_path, |
| 36 GDataEntry* entry) = 0; |
| 37 }; |
| 38 |
| 39 // Delegate used to find a directory element for file system updates. |
| 40 class ReadOnlyFindEntryDelegate : public FindEntryDelegate { |
| 41 public: |
| 42 ReadOnlyFindEntryDelegate(); |
| 43 |
| 44 // Returns found entry. |
| 45 GDataEntry* entry() { return entry_; } |
| 46 |
| 47 private: |
| 48 // FindEntryDelegate overrides. |
| 49 virtual void OnDone(base::PlatformFileError error, |
| 50 const FilePath& directory_path, |
| 51 GDataEntry* entry) OVERRIDE; |
| 52 |
| 53 // Entry that was found. |
| 54 GDataEntry* entry_; |
| 55 }; |
| 56 |
| 57 // FindEntryCallbackRelayDelegate class implementation. |
| 58 // This class is used to relay calls between sync and async versions |
| 59 // of FindFileByPath(Sync|Async) calls. |
| 60 class FindEntryCallbackRelayDelegate : public FindEntryDelegate { |
| 61 public: |
| 62 explicit FindEntryCallbackRelayDelegate(const FindEntryCallback& callback); |
| 63 virtual ~FindEntryCallbackRelayDelegate(); |
| 64 |
| 65 private: |
| 66 // FindEntryDelegate overrides. |
| 67 virtual void OnDone(base::PlatformFileError error, |
| 68 const FilePath& directory_path, |
| 69 GDataEntry* entry) OVERRIDE; |
| 70 |
| 71 const FindEntryCallback callback_; |
| 72 }; |
| 73 |
| 74 } // namespace gdata |
| 75 |
| 76 #endif // CHROME_BROWSER_CHROMEOS_GDATA_FIND_ENTRY_DELEGATE_H_ |
OLD | NEW |