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 CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 class FileTaskExecutor : public base::RefCountedThreadSafe<FileTaskExecutor> { | 75 class FileTaskExecutor : public base::RefCountedThreadSafe<FileTaskExecutor> { |
76 public: | 76 public: |
77 static const char kDriveTaskExtensionPrefix[]; | 77 static const char kDriveTaskExtensionPrefix[]; |
78 static const size_t kDriveTaskExtensionPrefixLength; | 78 static const size_t kDriveTaskExtensionPrefixLength; |
79 | 79 |
80 // Creates the appropriate FileTaskExecutor for the given |extension_id|. | 80 // Creates the appropriate FileTaskExecutor for the given |extension_id|. |
81 static FileTaskExecutor* Create(Profile* profile, | 81 static FileTaskExecutor* Create(Profile* profile, |
82 const GURL source_url, | 82 const GURL source_url, |
83 const std::string& extension_id, | 83 const std::string& extension_id, |
84 const std::string& action_id); | 84 const std::string& action_id); |
85 virtual ~FileTaskExecutor(); | |
86 | 85 |
87 // Same as ExecuteAndNotify, but no notification is performed. | 86 // Same as ExecuteAndNotify, but no notification is performed. |
88 virtual bool Execute(const std::vector<GURL>& file_urls); | 87 virtual bool Execute(const std::vector<GURL>& file_urls); |
89 | 88 |
90 // Initiates execution of file handler task for each element of |file_urls|. | 89 // Initiates execution of file handler task for each element of |file_urls|. |
91 // Return |false| if the execution cannot be initiated. Otherwise returns | 90 // Return |false| if the execution cannot be initiated. Otherwise returns |
92 // |true| and then eventually calls |done| when all the files have | 91 // |true| and then eventually calls |done| when all the files have |
93 // been handled. If there is an error during processing the list of files, the | 92 // been handled. If there is an error during processing the list of files, the |
94 // caller will be informed of the failure via |done|, and the rest of | 93 // caller will be informed of the failure via |done|, and the rest of |
95 // the files will not be processed. | 94 // the files will not be processed. |
96 virtual bool ExecuteAndNotify(const std::vector<GURL>& file_urls, | 95 virtual bool ExecuteAndNotify(const std::vector<GURL>& file_urls, |
97 const FileTaskFinishedCallback& done) = 0; | 96 const FileTaskFinishedCallback& done) = 0; |
98 | 97 |
99 protected: | 98 protected: |
100 explicit FileTaskExecutor(Profile* profile); | 99 explicit FileTaskExecutor(Profile* profile); |
| 100 virtual ~FileTaskExecutor(); |
101 | 101 |
102 // Returns the profile that this task was created with. | 102 // Returns the profile that this task was created with. |
103 Profile* profile() { return profile_; } | 103 Profile* profile() { return profile_; } |
104 | 104 |
105 // Returns a browser to use for the current browser. | 105 // Returns a browser to use for the current browser. |
106 Browser* GetBrowser() const; | 106 Browser* GetBrowser() const; |
107 private: | 107 private: |
| 108 friend class base::RefCountedThreadSafe<FileTaskExecutor>; |
108 | 109 |
109 Profile* profile_; | 110 Profile* profile_; |
110 }; | 111 }; |
111 | 112 |
112 } // namespace file_handler_util | 113 } // namespace file_handler_util |
113 | 114 |
114 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 115 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
OLD | NEW |