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

Side by Side Diff: content/renderer/history_entry.h

Issue 2705073003: Remove ScopedVector from content/renderer/. (Closed)
Patch Set: Fix win trybots Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /* 5 /*
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
8 * (http://www.torchmobile.com/) 8 * (http://www.torchmobile.com/)
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 18 matching lines...) Expand all
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35 #ifndef CONTENT_RENDERER_HISTORY_ENTRY_H_ 35 #ifndef CONTENT_RENDERER_HISTORY_ENTRY_H_
36 #define CONTENT_RENDERER_HISTORY_ENTRY_H_ 36 #define CONTENT_RENDERER_HISTORY_ENTRY_H_
37 37
38 #include <memory> 38 #include <memory>
39 #include <vector>
39 40
40 #include "base/containers/hash_tables.h" 41 #include "base/containers/hash_tables.h"
41 #include "base/memory/scoped_vector.h" 42 #include "base/macros.h"
42 #include "base/memory/weak_ptr.h" 43 #include "base/memory/weak_ptr.h"
43 #include "content/common/content_export.h" 44 #include "content/common/content_export.h"
44 #include "third_party/WebKit/public/platform/WebURLRequest.h" 45 #include "third_party/WebKit/public/platform/WebURLRequest.h"
45 #include "third_party/WebKit/public/web/WebHistoryItem.h" 46 #include "third_party/WebKit/public/web/WebHistoryItem.h"
46 47
47 namespace content { 48 namespace content {
48 class RenderFrameImpl; 49 class RenderFrameImpl;
49 class RenderViewImpl; 50 class RenderViewImpl;
50 51
51 class CONTENT_EXPORT HistoryEntry { 52 class CONTENT_EXPORT HistoryEntry {
52 public: 53 public:
53 class HistoryNode { 54 class CONTENT_EXPORT HistoryNode {
54 public: 55 public:
55 HistoryNode(const base::WeakPtr<HistoryEntry>& entry, 56 HistoryNode(const base::WeakPtr<HistoryEntry>& entry,
56 const blink::WebHistoryItem& item); 57 const blink::WebHistoryItem& item);
57 ~HistoryNode(); 58 ~HistoryNode();
58 59
59 HistoryNode* AddChild(const blink::WebHistoryItem& item); 60 HistoryNode* AddChild(const blink::WebHistoryItem& item);
60 HistoryNode* AddChild(); 61 HistoryNode* AddChild();
61 HistoryNode* CloneAndReplace(const base::WeakPtr<HistoryEntry>& new_entry, 62 std::unique_ptr<HistoryNode> CloneAndReplace(
62 const blink::WebHistoryItem& new_item, 63 const base::WeakPtr<HistoryEntry>& new_entry,
63 bool clone_children_of_target, 64 const blink::WebHistoryItem& new_item,
64 RenderFrameImpl* target_frame, 65 bool clone_children_of_target,
65 RenderFrameImpl* current_frame); 66 RenderFrameImpl* target_frame,
67 RenderFrameImpl* current_frame);
66 blink::WebHistoryItem& item() { return item_; } 68 blink::WebHistoryItem& item() { return item_; }
67 void set_item(const blink::WebHistoryItem& item); 69 void set_item(const blink::WebHistoryItem& item);
68 std::vector<HistoryNode*>& children() const { return children_->get(); } 70 std::vector<HistoryNode*> children() const;
69 void RemoveChildren(); 71 void RemoveChildren();
70 72
71 private: 73 private:
72 // When a HistoryEntry is destroyed, it takes all its HistoryNodes with it. 74 // When a HistoryEntry is destroyed, it takes all its HistoryNodes with it.
73 // Use a WeakPtr to ensure that HistoryNodes don't try to illegally access 75 // Use a WeakPtr to ensure that HistoryNodes don't try to illegally access
74 // a dying HistoryEntry, or do unnecessary work when the whole entry is 76 // a dying HistoryEntry, or do unnecessary work when the whole entry is
75 // being destroyed. 77 // being destroyed.
76 base::WeakPtr<HistoryEntry> entry_; 78 base::WeakPtr<HistoryEntry> entry_;
77 std::unique_ptr<ScopedVector<HistoryNode>> children_; 79 std::vector<std::unique_ptr<HistoryNode>> children_;
78 blink::WebHistoryItem item_; 80 blink::WebHistoryItem item_;
79 // We need to track multiple names because the name of a frame can change 81 // We need to track multiple names because the name of a frame can change
80 // over its lifetime. This allows us to clean up all of the names this node 82 // over its lifetime. This allows us to clean up all of the names this node
81 // has ever known by when it is destroyed. 83 // has ever known by when it is destroyed.
82 std::vector<std::string> unique_names_; 84 std::vector<std::string> unique_names_;
85
86 DISALLOW_COPY_AND_ASSIGN(HistoryNode);
Avi (use Gerrit) 2017/02/22 16:48:15 Yep, I've seen this on Windows builds before... :)
leonhsl(Using Gerrit) 2017/02/23 01:52:33 Sometimes Windows is special:-)
83 }; 87 };
84 88
85 HistoryEntry(const blink::WebHistoryItem& root); 89 HistoryEntry(const blink::WebHistoryItem& root);
86 HistoryEntry(); 90 HistoryEntry();
87 ~HistoryEntry(); 91 ~HistoryEntry();
88 92
89 HistoryEntry* CloneAndReplace(const blink::WebHistoryItem& newItem, 93 HistoryEntry* CloneAndReplace(const blink::WebHistoryItem& newItem,
90 bool clone_children_of_target, 94 bool clone_children_of_target,
91 RenderFrameImpl* target_frame, 95 RenderFrameImpl* target_frame,
92 RenderViewImpl* render_view); 96 RenderViewImpl* render_view);
93 97
94 HistoryNode* GetHistoryNodeForFrame(RenderFrameImpl* frame); 98 HistoryNode* GetHistoryNodeForFrame(RenderFrameImpl* frame);
95 blink::WebHistoryItem GetItemForFrame(RenderFrameImpl* frame); 99 blink::WebHistoryItem GetItemForFrame(RenderFrameImpl* frame);
96 const blink::WebHistoryItem& root() const { return root_->item(); } 100 const blink::WebHistoryItem& root() const { return root_->item(); }
97 HistoryNode* root_history_node() const { return root_.get(); } 101 HistoryNode* root_history_node() const { return root_.get(); }
98 102
99 private: 103 private:
100 std::unique_ptr<HistoryNode> root_; 104 std::unique_ptr<HistoryNode> root_;
101 105
102 typedef base::hash_map<std::string, HistoryNode*> UniqueNamesToItems; 106 typedef base::hash_map<std::string, HistoryNode*> UniqueNamesToItems;
103 UniqueNamesToItems unique_names_to_items_; 107 UniqueNamesToItems unique_names_to_items_;
104 108
105 base::WeakPtrFactory<HistoryEntry> weak_ptr_factory_; 109 base::WeakPtrFactory<HistoryEntry> weak_ptr_factory_;
110
111 DISALLOW_COPY_AND_ASSIGN(HistoryEntry);
106 }; 112 };
107 113
108 } // namespace content 114 } // namespace content
109 115
110 #endif // CONTENT_RENDERER_HISTORY_ENTRY_H_ 116 #endif // CONTENT_RENDERER_HISTORY_ENTRY_H_
OLDNEW
« no previous file with comments | « content/renderer/gpu/queue_message_swap_promise_unittest.cc ('k') | content/renderer/history_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698