Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_system / create_directory_operation.h
blobb06b6c9c9a24a4c5a2fb0623bd603367315b6c0d
1 // Copyright (c) 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h"
14 #include "components/drive/file_errors.h"
16 namespace base {
17 class FilePath;
18 class SequencedTaskRunner;
19 } // namespace base
21 namespace drive {
23 class FileChange;
24 class ResourceEntry;
26 namespace internal {
27 class ResourceMetadata;
28 } // namespace internal
30 namespace file_system {
32 class OperationDelegate;
34 // This class encapsulates the drive Create Directory function. It is
35 // responsible for sending the request to the drive API, then updating the
36 // local state and metadata to reflect the new state.
37 class CreateDirectoryOperation {
38 public:
39 CreateDirectoryOperation(base::SequencedTaskRunner* blocking_task_runner,
40 OperationDelegate* delegate,
41 internal::ResourceMetadata* metadata);
42 ~CreateDirectoryOperation();
44 // Creates a new directory at |directory_path|.
45 // If |is_exclusive| is true, an error is raised in case a directory exists
46 // already at the |directory_path|.
47 // If |is_recursive| is true, the invocation creates parent directories as
48 // needed just like mkdir -p does.
49 // Invokes |callback| when finished with the result of the operation.
50 // |callback| must not be null.
51 void CreateDirectory(const base::FilePath& directory_path,
52 bool is_exclusive,
53 bool is_recursive,
54 const FileOperationCallback& callback);
56 private:
57 // Part of CreateDirectory(). Called after UpdateLocalState().
58 void CreateDirectoryAfterUpdateLocalState(
59 const FileOperationCallback& callback,
60 const std::set<std::string>* updated_local_ids,
61 const FileChange* changed_directories,
62 FileError error);
64 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
65 OperationDelegate* delegate_;
66 internal::ResourceMetadata* metadata_;
68 base::ThreadChecker thread_checker_;
70 // Note: This should remain the last member so it'll be destroyed and
71 // invalidate the weak pointers before any other members are destroyed.
72 base::WeakPtrFactory<CreateDirectoryOperation> weak_ptr_factory_;
73 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation);
76 } // namespace file_system
77 } // namespace drive
79 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_