OLD | NEW |
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" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 Pickle* pickle) { | 43 Pickle* pickle) { |
44 DCHECK(pickle); | 44 DCHECK(pickle); |
45 | 45 |
46 if (!internal::WriteHeaderToPickle(pickle)) | 46 if (!internal::WriteHeaderToPickle(pickle)) |
47 return false; | 47 return false; |
48 | 48 |
49 const content::NavigationController& controller = | 49 const content::NavigationController& controller = |
50 web_contents.GetController(); | 50 web_contents.GetController(); |
51 const int entry_count = controller.GetEntryCount(); | 51 const int entry_count = controller.GetEntryCount(); |
52 const int selected_entry = controller.GetCurrentEntryIndex(); | 52 const int selected_entry = controller.GetCurrentEntryIndex(); |
53 DCHECK(entry_count >= 0); | 53 DCHECK_GE(entry_count, 0); |
54 DCHECK(selected_entry >= -1); // -1 is valid | 54 DCHECK_GE(selected_entry, -1); // -1 is valid |
55 DCHECK(selected_entry < entry_count); | 55 DCHECK_LT(selected_entry, entry_count); |
56 | 56 |
57 if (!pickle->WriteInt(entry_count)) | 57 if (!pickle->WriteInt(entry_count)) |
58 return false; | 58 return false; |
59 | 59 |
60 if (!pickle->WriteInt(selected_entry)) | 60 if (!pickle->WriteInt(selected_entry)) |
61 return false; | 61 return false; |
62 | 62 |
63 for (int i = 0; i < entry_count; ++i) { | 63 for (int i = 0; i < entry_count; ++i) { |
64 if (!internal::WriteNavigationEntryToPickle(*controller.GetEntryAtIndex(i), | 64 if (!internal::WriteNavigationEntryToPickle(*controller.GetEntryAtIndex(i), |
65 pickle)) | 65 pickle)) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return false; | 281 return false; |
282 entry->SetHttpStatusCode(http_status_code); | 282 entry->SetHttpStatusCode(http_status_code); |
283 } | 283 } |
284 | 284 |
285 return true; | 285 return true; |
286 } | 286 } |
287 | 287 |
288 } // namespace internal | 288 } // namespace internal |
289 | 289 |
290 } // namespace android_webview | 290 } // namespace android_webview |
OLD | NEW |