Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_task_executor.h
blob45e41e68169171b3be8af770154c75a37858ba0e
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_TASK_EXECUTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_TASK_EXECUTOR_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
14 #include "components/drive/file_errors.h"
15 #include "google_apis/drive/drive_api_error_codes.h"
17 namespace drive {
19 class DriveServiceInterface;
20 class FileSystemInterface;
21 class ResourceEntry;
23 // Delegate class for hooking fake instances and behaviors for testing.
24 class FileTaskExecutorDelegate {
25 public:
26 virtual ~FileTaskExecutorDelegate() {}
28 virtual FileSystemInterface* GetFileSystem() = 0;
29 virtual DriveServiceInterface* GetDriveService() = 0;
30 virtual void OpenBrowserWindow(const GURL& open_link) = 0;
33 // This class implements an "executor" class that will execute tasks for
34 // third party Drive apps that store data in Drive itself. To do that, it
35 // needs to find the file resource IDs and pass them to a server-side function
36 // that will authorize the app to open the given document and return a URL
37 // for opening the document in that app directly.
38 class FileTaskExecutor {
39 public:
40 // Creates FileTaskExecutor with delegate derived from |profile|. Used in
41 // product environment.
42 FileTaskExecutor(Profile* profile, const std::string& app_id);
44 // Creates FileTaskExecutor with a specific delegate.
45 FileTaskExecutor(scoped_ptr<FileTaskExecutorDelegate> delegate,
46 const std::string& app_id);
48 // Executes file tasks, runs |done| and deletes |this|.
49 void Execute(const std::vector<storage::FileSystemURL>& file_urls,
50 const file_manager::file_tasks::FileTaskFinishedCallback& done);
52 private:
53 ~FileTaskExecutor();
55 void OnFileEntryFetched(FileError error, scoped_ptr<ResourceEntry> entry);
56 void OnAppAuthorized(const std::string& resource_id,
57 google_apis::DriveApiErrorCode error,
58 const GURL& open_link);
60 // Calls |done_| with |success| status and deletes |this|.
61 void Done(bool success);
63 scoped_ptr<FileTaskExecutorDelegate> delegate_;
64 std::string app_id_;
65 int current_index_;
66 file_manager::file_tasks::FileTaskFinishedCallback done_;
68 base::WeakPtrFactory<FileTaskExecutor> weak_ptr_factory_;
71 } // namespace drive
73 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_TASK_EXECUTOR_H_