Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_system / create_directory_operation.h
blobf77a599be0bcd2a709d2fedd0784d16b20558cba
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 "chrome/browser/chromeos/drive/file_errors.h"
15 namespace base {
16 class FilePath;
17 class SequencedTaskRunner;
18 } // namespace base
20 namespace drive {
22 class FileChange;
23 class ResourceEntry;
25 namespace internal {
26 class ResourceMetadata;
27 } // namespace internal
29 namespace file_system {
31 class OperationDelegate;
33 // This class encapsulates the drive Create Directory function. It is
34 // responsible for sending the request to the drive API, then updating the
35 // local state and metadata to reflect the new state.
36 class CreateDirectoryOperation {
37 public:
38 CreateDirectoryOperation(base::SequencedTaskRunner* blocking_task_runner,
39 OperationDelegate* delegate,
40 internal::ResourceMetadata* metadata);
41 ~CreateDirectoryOperation();
43 // Creates a new directory at |directory_path|.
44 // If |is_exclusive| is true, an error is raised in case a directory exists
45 // already at the |directory_path|.
46 // If |is_recursive| is true, the invocation creates parent directories as
47 // needed just like mkdir -p does.
48 // Invokes |callback| when finished with the result of the operation.
49 // |callback| must not be null.
50 void CreateDirectory(const base::FilePath& directory_path,
51 bool is_exclusive,
52 bool is_recursive,
53 const FileOperationCallback& callback);
55 private:
56 // Part of CreateDirectory(). Called after UpdateLocalState().
57 void CreateDirectoryAfterUpdateLocalState(
58 const FileOperationCallback& callback,
59 const std::set<std::string>* updated_local_ids,
60 const FileChange* changed_directories,
61 FileError error);
63 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
64 OperationDelegate* delegate_;
65 internal::ResourceMetadata* metadata_;
67 // Note: This should remain the last member so it'll be destroyed and
68 // invalidate the weak pointers before any other members are destroyed.
69 base::WeakPtrFactory<CreateDirectoryOperation> weak_ptr_factory_;
70 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation);
73 } // namespace file_system
74 } // namespace drive
76 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_DIRECTORY_OPERATION_H_