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

Side by Side Diff: android_webview/native/state_serializer.cc

Issue 1440573003: Remove ScopedVector from NavigationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: aw Created 5 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "android_webview/native/state_serializer.h" 5 #include "android_webview/native/state_serializer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_vector.h"
10 #include "base/pickle.h" 9 #include "base/pickle.h"
11 #include "base/time/time.h" 10 #include "base/time/time.h"
12 #include "content/public/browser/child_process_security_policy.h" 11 #include "content/public/browser/child_process_security_policy.h"
13 #include "content/public/browser/navigation_controller.h" 12 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/page_state.h" 16 #include "content/public/common/page_state.h"
18 17
19 // Reasons for not re-using TabNavigation under chrome/ as of 20121116: 18 // Reasons for not re-using TabNavigation under chrome/ as of 20121116:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (!iterator->ReadInt(&selected_entry)) 87 if (!iterator->ReadInt(&selected_entry))
89 return false; 88 return false;
90 89
91 if (entry_count < 0) 90 if (entry_count < 0)
92 return false; 91 return false;
93 if (selected_entry < -1) 92 if (selected_entry < -1)
94 return false; 93 return false;
95 if (selected_entry >= entry_count) 94 if (selected_entry >= entry_count)
96 return false; 95 return false;
97 96
98 ScopedVector<content::NavigationEntry> restored_entries; 97 std::vector<scoped_ptr<content::NavigationEntry>> entries;
ncarter (slow) 2015/11/12 18:10:40 Might as well: entries.reserve(entry_count) ?
Avi (use Gerrit) 2015/11/12 19:13:04 Done.
99 for (int i = 0; i < entry_count; ++i) { 98 for (int i = 0; i < entry_count; ++i) {
100 restored_entries.push_back(content::NavigationEntry::Create()); 99 entries.push_back(content::NavigationEntry::Create());
101 if (!internal::RestoreNavigationEntryFromPickle(iterator, 100 if (!internal::RestoreNavigationEntryFromPickle(iterator, entries[i].get()))
102 restored_entries[i]))
103 return false; 101 return false;
104 102
105 restored_entries[i]->SetPageID(i); 103 entries[i]->SetPageID(i);
106 } 104 }
107 105
108 // |web_contents| takes ownership of these entries after this call. 106 // |web_contents| takes ownership of these entries after this call.
109 content::NavigationController& controller = web_contents->GetController(); 107 content::NavigationController& controller = web_contents->GetController();
110 controller.Restore( 108 controller.Restore(
111 selected_entry, 109 selected_entry,
112 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, 110 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY,
113 &restored_entries); 111 &entries);
114 DCHECK_EQ(0u, restored_entries.size()); 112 DCHECK_EQ(0u, entries.size());
115 113
116 if (controller.GetLastCommittedEntry()) { 114 if (controller.GetLastCommittedEntry()) {
117 // Set up the file access rights for the selected navigation entry. 115 // Set up the file access rights for the selected navigation entry.
118 // TODO(joth): This is duplicated from chrome/.../session_restore.cc and 116 // TODO(joth): This is duplicated from chrome/.../session_restore.cc and
119 // should be shared e.g. in NavigationController. http://crbug.com/68222 117 // should be shared e.g. in NavigationController. http://crbug.com/68222
120 const int id = web_contents->GetRenderProcessHost()->GetID(); 118 const int id = web_contents->GetRenderProcessHost()->GetID();
121 const content::PageState& page_state = 119 const content::PageState& page_state =
122 controller.GetLastCommittedEntry()->GetPageState(); 120 controller.GetLastCommittedEntry()->GetPageState();
123 const std::vector<base::FilePath>& file_paths = 121 const std::vector<base::FilePath>& file_paths =
124 page_state.GetReferencedFiles(); 122 page_state.GetReferencedFiles();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return false; 279 return false;
282 entry->SetHttpStatusCode(http_status_code); 280 entry->SetHttpStatusCode(http_status_code);
283 } 281 }
284 282
285 return true; 283 return true;
286 } 284 }
287 285
288 } // namespace internal 286 } // namespace internal
289 287
290 } // namespace android_webview 288 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698