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

Side by Side Diff: chrome/browser/sessions/base_session_service.cc

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jar feedback Created 8 years, 9 months 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 | Annotate | Revision Log
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 "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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return new SessionCommand(command_id, pickle); 247 return new SessionCommand(command_id, pickle);
248 } 248 }
249 249
250 bool BaseSessionService::RestoreUpdateTabNavigationCommand( 250 bool BaseSessionService::RestoreUpdateTabNavigationCommand(
251 const SessionCommand& command, 251 const SessionCommand& command,
252 TabNavigation* navigation, 252 TabNavigation* navigation,
253 SessionID::id_type* tab_id) { 253 SessionID::id_type* tab_id) {
254 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); 254 scoped_ptr<Pickle> pickle(command.PayloadAsPickle());
255 if (!pickle.get()) 255 if (!pickle.get())
256 return false; 256 return false;
257 void* iterator = NULL; 257 PickleReader iterator(*pickle);
258 std::string url_spec; 258 std::string url_spec;
259 if (!pickle->ReadInt(&iterator, tab_id) || 259 if (!pickle->ReadInt(&iterator, tab_id) ||
260 !pickle->ReadInt(&iterator, &(navigation->index_)) || 260 !pickle->ReadInt(&iterator, &(navigation->index_)) ||
261 !pickle->ReadString(&iterator, &url_spec) || 261 !pickle->ReadString(&iterator, &url_spec) ||
262 !pickle->ReadString16(&iterator, &(navigation->title_)) || 262 !pickle->ReadString16(&iterator, &(navigation->title_)) ||
263 !pickle->ReadString(&iterator, &(navigation->state_)) || 263 !pickle->ReadString(&iterator, &(navigation->state_)) ||
264 !pickle->ReadInt(&iterator, 264 !pickle->ReadInt(&iterator,
265 reinterpret_cast<int*>(&(navigation->transition_)))) 265 reinterpret_cast<int*>(&(navigation->transition_))))
266 return false; 266 return false;
267 // type_mask did not always exist in the written stream. As such, we 267 // type_mask did not always exist in the written stream. As such, we
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( 301 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand(
302 const SessionCommand& command, 302 const SessionCommand& command,
303 SessionID::id_type* tab_id, 303 SessionID::id_type* tab_id,
304 std::string* extension_app_id) { 304 std::string* extension_app_id) {
305 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); 305 scoped_ptr<Pickle> pickle(command.PayloadAsPickle());
306 if (!pickle.get()) 306 if (!pickle.get())
307 return false; 307 return false;
308 308
309 void* iterator = NULL; 309 PickleReader iterator(*pickle);
310 return pickle->ReadInt(&iterator, tab_id) && 310 return pickle->ReadInt(&iterator, tab_id) &&
311 pickle->ReadString(&iterator, extension_app_id); 311 pickle->ReadString(&iterator, extension_app_id);
312 } 312 }
313 313
314 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { 314 bool BaseSessionService::ShouldTrackEntry(const GURL& url) {
315 // NOTE: Do not track print preview tab because re-opening that page will 315 // NOTE: Do not track print preview tab because re-opening that page will
316 // just display a non-functional print preview page. 316 // just display a non-functional print preview page.
317 return url.is_valid() && url != GURL(chrome::kChromeUIPrintURL); 317 return url.is_valid() && url != GURL(chrome::kChromeUIPrintURL);
318 } 318 }
319 319
(...skipping 19 matching lines...) Expand all
339 if (RunningInProduction()) { 339 if (RunningInProduction()) {
340 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); 340 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task);
341 } else { 341 } else {
342 // Fall back to executing on the main thread if the file thread 342 // Fall back to executing on the main thread if the file thread
343 // has gone away (around shutdown time) or if we're running as 343 // has gone away (around shutdown time) or if we're running as
344 // part of a unit test that does not set profile_. 344 // part of a unit test that does not set profile_.
345 task.Run(); 345 task.Run();
346 return true; 346 return true;
347 } 347 }
348 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698