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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 static const SessionCommand::size_type max_id_size = | 212 static const SessionCommand::size_type max_id_size = |
213 std::numeric_limits<SessionCommand::size_type>::max() - 1024; | 213 std::numeric_limits<SessionCommand::size_type>::max() - 1024; |
214 | 214 |
215 int bytes_written = 0; | 215 int bytes_written = 0; |
216 | 216 |
217 WriteStringToPickle(pickle, &bytes_written, max_id_size, app_name); | 217 WriteStringToPickle(pickle, &bytes_written, max_id_size, app_name); |
218 | 218 |
219 return new SessionCommand(command_id, pickle); | 219 return new SessionCommand(command_id, pickle); |
220 } | 220 } |
221 | 221 |
| 222 SessionCommand* BaseSessionService::CreateSetTabSessionSyncIdCommand( |
| 223 SessionID::id_type command_id, |
| 224 SessionID::id_type tab_id, |
| 225 const int64& sync_id) { |
| 226 // Use pickle to handle marshalling. |
| 227 Pickle pickle; |
| 228 pickle.WriteInt(tab_id); |
| 229 pickle.WriteInt64(sync_id); |
| 230 |
| 231 return new SessionCommand(command_id, pickle); |
| 232 } |
| 233 |
222 bool BaseSessionService::RestoreUpdateTabNavigationCommand( | 234 bool BaseSessionService::RestoreUpdateTabNavigationCommand( |
223 const SessionCommand& command, | 235 const SessionCommand& command, |
224 sessions::SerializedNavigationEntry* navigation, | 236 sessions::SerializedNavigationEntry* navigation, |
225 SessionID::id_type* tab_id) { | 237 SessionID::id_type* tab_id) { |
226 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); | 238 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); |
227 if (!pickle.get()) | 239 if (!pickle.get()) |
228 return false; | 240 return false; |
229 PickleIterator iterator(*pickle); | 241 PickleIterator iterator(*pickle); |
230 return | 242 return |
231 pickle->ReadInt(&iterator, tab_id) && | 243 pickle->ReadInt(&iterator, tab_id) && |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 std::string* app_name) { | 276 std::string* app_name) { |
265 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); | 277 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); |
266 if (!pickle.get()) | 278 if (!pickle.get()) |
267 return false; | 279 return false; |
268 | 280 |
269 PickleIterator iterator(*pickle); | 281 PickleIterator iterator(*pickle); |
270 return pickle->ReadInt(&iterator, window_id) && | 282 return pickle->ReadInt(&iterator, window_id) && |
271 pickle->ReadString(&iterator, app_name); | 283 pickle->ReadString(&iterator, app_name); |
272 } | 284 } |
273 | 285 |
| 286 bool BaseSessionService::RestoreSetTabSessionSyncIdCommand( |
| 287 const SessionCommand& command, |
| 288 SessionID::id_type* tab_id, |
| 289 int64* sync_id) { |
| 290 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); |
| 291 if (!pickle.get()) |
| 292 return false; |
| 293 |
| 294 PickleIterator iterator(*pickle); |
| 295 return pickle->ReadInt(&iterator, tab_id) && |
| 296 pickle->ReadInt64(&iterator, sync_id); |
| 297 } |
| 298 |
274 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { | 299 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { |
275 return url.is_valid(); | 300 return url.is_valid(); |
276 } | 301 } |
277 | 302 |
278 CancelableTaskTracker::TaskId | 303 CancelableTaskTracker::TaskId |
279 BaseSessionService::ScheduleGetLastSessionCommands( | 304 BaseSessionService::ScheduleGetLastSessionCommands( |
280 const InternalGetCommandsCallback& callback, | 305 const InternalGetCommandsCallback& callback, |
281 CancelableTaskTracker* tracker) { | 306 CancelableTaskTracker* tracker) { |
282 CancelableTaskTracker::IsCanceledCallback is_canceled; | 307 CancelableTaskTracker::IsCanceledCallback is_canceled; |
283 CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); | 308 CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); |
(...skipping 22 matching lines...) Expand all Loading... |
306 // has gone away (around shutdown time) or if we're running as | 331 // has gone away (around shutdown time) or if we're running as |
307 // part of a unit test that does not set profile_. | 332 // part of a unit test that does not set profile_. |
308 task.Run(); | 333 task.Run(); |
309 return true; | 334 return true; |
310 } | 335 } |
311 } | 336 } |
312 | 337 |
313 bool BaseSessionService::RunningInProduction() const { | 338 bool BaseSessionService::RunningInProduction() const { |
314 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); | 339 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); |
315 } | 340 } |
OLD | NEW |