Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: components/undo/undo_manager.h

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_UNDO_UNDO_MANAGER_H_ 5 #ifndef COMPONENTS_UNDO_UNDO_MANAGER_H_
6 #define COMPONENTS_UNDO_UNDO_MANAGER_H_ 6 #define COMPONENTS_UNDO_UNDO_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 16
16 class UndoManagerObserver; 17 class UndoManagerObserver;
17 class UndoOperation; 18 class UndoOperation;
18 19
19 // UndoGroup ------------------------------------------------------------------ 20 // UndoGroup ------------------------------------------------------------------
20 21
21 // UndoGroup represents a user action and stores all the operations that 22 // UndoGroup represents a user action and stores all the operations that
22 // make that action. Typically there is only one operation per UndoGroup. 23 // make that action. Typically there is only one operation per UndoGroup.
23 class UndoGroup { 24 class UndoGroup {
24 public: 25 public:
25 UndoGroup(); 26 UndoGroup();
26 ~UndoGroup(); 27 ~UndoGroup();
27 28
28 void AddOperation(scoped_ptr<UndoOperation> operation); 29 void AddOperation(std::unique_ptr<UndoOperation> operation);
29 const std::vector<UndoOperation*>& undo_operations() { 30 const std::vector<UndoOperation*>& undo_operations() {
30 return operations_.get(); 31 return operations_.get();
31 } 32 }
32 void Undo(); 33 void Undo();
33 34
34 // The resource string id describing the undo and redo action. 35 // The resource string id describing the undo and redo action.
35 int get_undo_label_id() const { return undo_label_id_; } 36 int get_undo_label_id() const { return undo_label_id_; }
36 void set_undo_label_id(int label_id) { undo_label_id_ = label_id; } 37 void set_undo_label_id(int label_id) { undo_label_id_ = label_id; }
37 38
38 int get_redo_label_id() const { return redo_label_id_; } 39 int get_redo_label_id() const { return redo_label_id_; }
(...skipping 21 matching lines...) Expand all
60 // Perform an undo or redo operation. 61 // Perform an undo or redo operation.
61 void Undo(); 62 void Undo();
62 void Redo(); 63 void Redo();
63 64
64 size_t undo_count() const { return undo_actions_.size(); } 65 size_t undo_count() const { return undo_actions_.size(); }
65 size_t redo_count() const { return redo_actions_.size(); } 66 size_t redo_count() const { return redo_actions_.size(); }
66 67
67 base::string16 GetUndoLabel() const; 68 base::string16 GetUndoLabel() const;
68 base::string16 GetRedoLabel() const; 69 base::string16 GetRedoLabel() const;
69 70
70 void AddUndoOperation(scoped_ptr<UndoOperation> operation); 71 void AddUndoOperation(std::unique_ptr<UndoOperation> operation);
71 72
72 // Group multiple operations into one undoable action. 73 // Group multiple operations into one undoable action.
73 void StartGroupingActions(); 74 void StartGroupingActions();
74 void EndGroupingActions(); 75 void EndGroupingActions();
75 76
76 // Suspend undo tracking while processing non-user initiated changes such as 77 // Suspend undo tracking while processing non-user initiated changes such as
77 // profile synchonization. 78 // profile synchonization.
78 void SuspendUndoTracking(); 79 void SuspendUndoTracking();
79 void ResumeUndoTracking(); 80 void ResumeUndoTracking();
80 bool IsUndoTrakingSuspended() const; 81 bool IsUndoTrakingSuspended() const;
(...skipping 29 matching lines...) Expand all
110 ScopedVector<UndoGroup> undo_actions_; 111 ScopedVector<UndoGroup> undo_actions_;
111 ScopedVector<UndoGroup> redo_actions_; 112 ScopedVector<UndoGroup> redo_actions_;
112 113
113 // The observers to notify when internal state changes. 114 // The observers to notify when internal state changes.
114 base::ObserverList<UndoManagerObserver> observers_; 115 base::ObserverList<UndoManagerObserver> observers_;
115 116
116 // Supports grouping operations into a single undo action. 117 // Supports grouping operations into a single undo action.
117 int group_actions_count_; 118 int group_actions_count_;
118 119
119 // The container that is used when actions are grouped. 120 // The container that is used when actions are grouped.
120 scoped_ptr<UndoGroup> pending_grouped_action_; 121 std::unique_ptr<UndoGroup> pending_grouped_action_;
121 122
122 // The action that is in the process of being undone. 123 // The action that is in the process of being undone.
123 UndoGroup* undo_in_progress_action_; 124 UndoGroup* undo_in_progress_action_;
124 125
125 // Supports the suspension of undo tracking. 126 // Supports the suspension of undo tracking.
126 int undo_suspended_count_; 127 int undo_suspended_count_;
127 128
128 // Set when executing Undo or Redo so that incoming changes are correctly 129 // Set when executing Undo or Redo so that incoming changes are correctly
129 // processed. 130 // processed.
130 bool performing_undo_; 131 bool performing_undo_;
131 bool performing_redo_; 132 bool performing_redo_;
132 133
133 DISALLOW_COPY_AND_ASSIGN(UndoManager); 134 DISALLOW_COPY_AND_ASSIGN(UndoManager);
134 }; 135 };
135 136
136 #endif // COMPONENTS_UNDO_UNDO_MANAGER_H_ 137 #endif // COMPONENTS_UNDO_UNDO_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698