Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 entry.content_state()); | 170 entry.content_state()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 pickle.WriteInt(entry.transition_type()); | 173 pickle.WriteInt(entry.transition_type()); |
| 174 int type_mask = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; | 174 int type_mask = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; |
| 175 pickle.WriteInt(type_mask); | 175 pickle.WriteInt(type_mask); |
| 176 | 176 |
| 177 WriteStringToPickle(pickle, &bytes_written, max_state_size, | 177 WriteStringToPickle(pickle, &bytes_written, max_state_size, |
| 178 entry.referrer().is_valid() ? entry.referrer().spec() : std::string()); | 178 entry.referrer().is_valid() ? entry.referrer().spec() : std::string()); |
| 179 | 179 |
| 180 WriteStringToPickle(pickle, &bytes_written, max_state_size, | |
|
sky
2011/08/30 20:16:33
Add test coverage of this.
Roger Tawa OOO till Jul 10th
2011/08/31 20:14:01
Done.
| |
| 181 entry.extra_headers()); | |
| 182 | |
| 180 // Adding more data? Be sure and update TabRestoreService too. | 183 // Adding more data? Be sure and update TabRestoreService too. |
| 181 return new SessionCommand(command_id, pickle); | 184 return new SessionCommand(command_id, pickle); |
| 182 } | 185 } |
| 183 | 186 |
| 184 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( | 187 SessionCommand* BaseSessionService::CreateSetTabExtensionAppIDCommand( |
| 185 SessionID::id_type command_id, | 188 SessionID::id_type command_id, |
| 186 SessionID::id_type tab_id, | 189 SessionID::id_type tab_id, |
| 187 const std::string& extension_id) { | 190 const std::string& extension_id) { |
| 188 // Use pickle to handle marshalling. | 191 // Use pickle to handle marshalling. |
| 189 Pickle pickle; | 192 Pickle pickle; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 218 reinterpret_cast<int*>(&(navigation->transition_)))) | 221 reinterpret_cast<int*>(&(navigation->transition_)))) |
| 219 return false; | 222 return false; |
| 220 // type_mask did not always exist in the written stream. As such, we | 223 // type_mask did not always exist in the written stream. As such, we |
| 221 // don't fail if it can't be read. | 224 // don't fail if it can't be read. |
| 222 bool has_type_mask = pickle->ReadInt(&iterator, &(navigation->type_mask_)); | 225 bool has_type_mask = pickle->ReadInt(&iterator, &(navigation->type_mask_)); |
| 223 | 226 |
| 224 if (has_type_mask) { | 227 if (has_type_mask) { |
| 225 // the "referrer" property was added after type_mask to the written | 228 // the "referrer" property was added after type_mask to the written |
| 226 // stream. As such, we don't fail if it can't be read. | 229 // stream. As such, we don't fail if it can't be read. |
| 227 std::string referrer_spec; | 230 std::string referrer_spec; |
| 228 pickle->ReadString(&iterator, &referrer_spec); | 231 bool has_referrer = pickle->ReadString(&iterator, &referrer_spec); |
| 229 if (!referrer_spec.empty()) | 232 if (!referrer_spec.empty()) |
| 230 navigation->referrer_ = GURL(referrer_spec); | 233 navigation->referrer_ = GURL(referrer_spec); |
| 234 | |
| 235 if (has_referrer) { | |
| 236 // the "extra_headers" property was added after referrer to the written | |
| 237 // stream. As such, we don't fail if it can't be read. | |
| 238 std::string extra_headers; | |
| 239 pickle->ReadString(&iterator, &extra_headers); | |
| 240 navigation->set_extra_headers(extra_headers); | |
| 241 } | |
| 231 } | 242 } |
| 232 | 243 |
| 233 navigation->virtual_url_ = GURL(url_spec); | 244 navigation->virtual_url_ = GURL(url_spec); |
| 234 return true; | 245 return true; |
| 235 } | 246 } |
| 236 | 247 |
| 237 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( | 248 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( |
| 238 const SessionCommand& command, | 249 const SessionCommand& command, |
| 239 SessionID::id_type* tab_id, | 250 SessionID::id_type* tab_id, |
| 240 std::string* extension_app_id) { | 251 std::string* extension_app_id) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 if (backend_thread()) { | 287 if (backend_thread()) { |
| 277 backend_thread()->message_loop()->PostTask(FROM_HERE, | 288 backend_thread()->message_loop()->PostTask(FROM_HERE, |
| 278 NewRunnableMethod(backend(), | 289 NewRunnableMethod(backend(), |
| 279 &SessionBackend::ReadCurrentSessionCommands, | 290 &SessionBackend::ReadCurrentSessionCommands, |
| 280 request_wrapper)); | 291 request_wrapper)); |
| 281 } else { | 292 } else { |
| 282 backend()->ReadCurrentSessionCommands(request); | 293 backend()->ReadCurrentSessionCommands(request); |
| 283 } | 294 } |
| 284 return request->handle(); | 295 return request->handle(); |
| 285 } | 296 } |
| OLD | NEW |