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 "chrome/browser/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 if (pending_reset_) { | 142 if (pending_reset_) { |
143 commands_since_reset_ = 0; | 143 commands_since_reset_ = 0; |
144 pending_reset_ = false; | 144 pending_reset_ = false; |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( | 148 SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( |
149 SessionID::id_type command_id, | 149 SessionID::id_type command_id, |
150 SessionID::id_type tab_id, | 150 SessionID::id_type tab_id, |
151 const TabNavigation& navigation) { | 151 const sessions::SerializedNavigationEntry& navigation) { |
152 // Use pickle to handle marshalling. | 152 // Use pickle to handle marshalling. |
153 Pickle pickle; | 153 Pickle pickle; |
154 pickle.WriteInt(tab_id); | 154 pickle.WriteInt(tab_id); |
155 navigation.WriteToPickle(&pickle); | 155 // We only allow navigations up to 63k (which should be completely |
| 156 // reasonable). |
| 157 static const size_t max_state_size = |
| 158 std::numeric_limits<SessionCommand::size_type>::max() - 1024; |
| 159 navigation.WriteToPickle(max_state_size, &pickle); |
156 return new SessionCommand(command_id, pickle); | 160 return new SessionCommand(command_id, pickle); |
157 } | 161 } |
158 | 162 |
159 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( | 163 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( |
160 SessionID::id_type command_id, | 164 SessionID::id_type command_id, |
161 SessionID::id_type tab_id, | 165 SessionID::id_type tab_id, |
162 const std::string& extension_id) { | 166 const std::string& extension_id) { |
163 // Use pickle to handle marshalling. | 167 // Use pickle to handle marshalling. |
164 Pickle pickle; | 168 Pickle pickle; |
165 pickle.WriteInt(tab_id); | 169 pickle.WriteInt(tab_id); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 214 |
211 int bytes_written = 0; | 215 int bytes_written = 0; |
212 | 216 |
213 WriteStringToPickle(pickle, &bytes_written, max_id_size, app_name); | 217 WriteStringToPickle(pickle, &bytes_written, max_id_size, app_name); |
214 | 218 |
215 return new SessionCommand(command_id, pickle); | 219 return new SessionCommand(command_id, pickle); |
216 } | 220 } |
217 | 221 |
218 bool BaseSessionService::RestoreUpdateTabNavigationCommand( | 222 bool BaseSessionService::RestoreUpdateTabNavigationCommand( |
219 const SessionCommand& command, | 223 const SessionCommand& command, |
220 TabNavigation* navigation, | 224 sessions::SerializedNavigationEntry* navigation, |
221 SessionID::id_type* tab_id) { | 225 SessionID::id_type* tab_id) { |
222 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); | 226 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); |
223 if (!pickle.get()) | 227 if (!pickle.get()) |
224 return false; | 228 return false; |
225 PickleIterator iterator(*pickle); | 229 PickleIterator iterator(*pickle); |
226 return | 230 return |
227 pickle->ReadInt(&iterator, tab_id) && | 231 pickle->ReadInt(&iterator, tab_id) && |
228 navigation->ReadFromPickle(&iterator); | 232 navigation->ReadFromPickle(&iterator); |
229 } | 233 } |
230 | 234 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // has gone away (around shutdown time) or if we're running as | 306 // has gone away (around shutdown time) or if we're running as |
303 // part of a unit test that does not set profile_. | 307 // part of a unit test that does not set profile_. |
304 task.Run(); | 308 task.Run(); |
305 return true; | 309 return true; |
306 } | 310 } |
307 } | 311 } |
308 | 312 |
309 bool BaseSessionService::RunningInProduction() const { | 313 bool BaseSessionService::RunningInProduction() const { |
310 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); | 314 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); |
311 } | 315 } |
OLD | NEW |