BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / components / drive / file_system / touch_operation.h
blob46c53e71a2beac34832e9dacd08bf6029fdac19a
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.
5 #ifndef COMPONENTS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_
6 #define COMPONENTS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "components/drive/file_errors.h"
14 namespace base {
15 class FilePath;
16 class SequencedTaskRunner;
17 class Time;
18 } // namespace base
20 namespace drive {
21 namespace internal {
22 class ResourceMetadata;
23 } // namespace internal
25 class ResourceEntry;
27 namespace file_system {
29 class OperationDelegate;
31 class TouchOperation {
32 public:
33 TouchOperation(base::SequencedTaskRunner* blocking_task_runner,
34 OperationDelegate* delegate,
35 internal::ResourceMetadata* metadata);
36 ~TouchOperation();
38 // Touches the file by updating last access time and last modified time.
39 // Upon completion, invokes |callback|.
40 // |last_access_time|, |last_modified_time| and |callback| must not be null.
41 void TouchFile(const base::FilePath& file_path,
42 const base::Time& last_access_time,
43 const base::Time& last_modified_time,
44 const FileOperationCallback& callback);
46 private:
47 // Part of TouchFile(). Runs after updating the local state.
48 void TouchFileAfterUpdateLocalState(const base::FilePath& file_path,
49 const FileOperationCallback& callback,
50 const ResourceEntry* entry,
51 FileError error);
53 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
54 OperationDelegate* delegate_;
55 internal::ResourceMetadata* metadata_;
57 base::ThreadChecker thread_checker_;
59 // Note: This should remain the last member so it'll be destroyed and
60 // invalidate the weak pointers before any other members are destroyed.
61 base::WeakPtrFactory<TouchOperation> weak_ptr_factory_;
62 DISALLOW_COPY_AND_ASSIGN(TouchOperation);
65 } // namespace file_system
66 } // namespace drive
68 #endif // COMPONENTS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_