Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync_file_system / drive_backend / folder_creator.h
1 // Copyright 2013 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_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FOLDER_CREATOR_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FOLDER_CREATOR_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync_file_system/sync_callbacks.h"
14 #include "google_apis/drive/gdata_errorcode.h"
15
16 namespace drive {
17 class DriveServiceInterface;
18 }
19
20 namespace google_apis {
21 class FileList;
22 class FileResource;
23 class ResourceEntry;
24 }
25
26 namespace sync_file_system {
27 namespace drive_backend {
28
29 class MetadataDatabase;
30 class SyncEngineContext;
31
32 class FolderCreator {
33  public:
34   typedef base::Callback<void(const std::string& file_id,
35                               SyncStatusCode status)> FileIDCallback;
36
37   FolderCreator(drive::DriveServiceInterface* drive_service,
38                 MetadataDatabase* metadata_database,
39                 const std::string& parent_folder_id,
40                 const std::string& title);
41   ~FolderCreator();
42
43   void Run(const FileIDCallback& callback);
44
45  private:
46   void DidCreateFolder(const FileIDCallback& callback,
47                        google_apis::GDataErrorCode error,
48                        scoped_ptr<google_apis::FileResource> entry);
49   void DidListFolders(const FileIDCallback& callback,
50                       ScopedVector<google_apis::FileResource> candidates,
51                       google_apis::GDataErrorCode error,
52                       scoped_ptr<google_apis::FileList> file_list);
53
54   drive::DriveServiceInterface* drive_service_;
55   MetadataDatabase* metadata_database_;
56
57   const std::string parent_folder_id_;
58   const std::string title_;
59
60   base::WeakPtrFactory<FolderCreator> weak_ptr_factory_;
61
62   DISALLOW_COPY_AND_ASSIGN(FolderCreator);
63 };
64
65 }  // namespace drive_backend
66 }  // namespace sync_file_system
67
68 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FOLDER_CREATOR_H_