Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_task_executor.h
blob0bdf6bcae1e31986a735537397239e0290a61dbc
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/drive/file_errors.h"
14 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
15 #include "google_apis/drive/gdata_errorcode.h"
17 namespace drive {
19 class ResourceEntry;
21 // This class implements an "executor" class that will execute tasks for
22 // third party Drive apps that store data in Drive itself. To do that, it
23 // needs to find the file resource IDs and pass them to a server-side function
24 // that will authorize the app to open the given document and return a URL
25 // for opening the document in that app directly.
26 class FileTaskExecutor {
27 public:
28 FileTaskExecutor(Profile* profile, const std::string& app_id);
30 // Executes file tasks, runs |done| and deletes |this|.
31 void Execute(
32 const std::vector<fileapi::FileSystemURL>& file_urls,
33 const file_manager::file_tasks::FileTaskFinishedCallback& done);
35 private:
36 ~FileTaskExecutor();
38 void OnFileEntryFetched(FileError error, scoped_ptr<ResourceEntry> entry);
39 void OnAppAuthorized(const std::string& resource_id,
40 google_apis::GDataErrorCode error,
41 const GURL& open_link);
43 // Calls |done_| with |success| status and deletes |this|.
44 void Done(bool success);
46 Profile* profile_;
47 std::string app_id_;
48 int current_index_;
49 file_manager::file_tasks::FileTaskFinishedCallback done_;
51 base::WeakPtrFactory<FileTaskExecutor> weak_ptr_factory_;
54 } // namespace drive
56 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_TASK_EXECUTOR_H_