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

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: compile (racing with incoming CLs) 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return new SessionCommand(command_id, pickle); 266 return new SessionCommand(command_id, pickle);
267 } 267 }
268 268
269 bool BaseSessionService::RestoreUpdateTabNavigationCommand( 269 bool BaseSessionService::RestoreUpdateTabNavigationCommand(
270 const SessionCommand& command, 270 const SessionCommand& command,
271 TabNavigation* navigation, 271 TabNavigation* navigation,
272 SessionID::id_type* tab_id) { 272 SessionID::id_type* tab_id) {
273 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); 273 scoped_ptr<Pickle> pickle(command.PayloadAsPickle());
274 if (!pickle.get()) 274 if (!pickle.get())
275 return false; 275 return false;
276 void* iterator = NULL; 276 PickleIterator iterator(*pickle);
277 std::string url_spec; 277 std::string url_spec;
278 if (!pickle->ReadInt(&iterator, tab_id) || 278 if (!pickle->ReadInt(&iterator, tab_id) ||
279 !pickle->ReadInt(&iterator, &(navigation->index_)) || 279 !pickle->ReadInt(&iterator, &(navigation->index_)) ||
280 !pickle->ReadString(&iterator, &url_spec) || 280 !pickle->ReadString(&iterator, &url_spec) ||
281 !pickle->ReadString16(&iterator, &(navigation->title_)) || 281 !pickle->ReadString16(&iterator, &(navigation->title_)) ||
282 !pickle->ReadString(&iterator, &(navigation->state_)) || 282 !pickle->ReadString(&iterator, &(navigation->state_)) ||
283 !pickle->ReadInt(&iterator, 283 !pickle->ReadInt(&iterator,
284 reinterpret_cast<int*>(&(navigation->transition_)))) 284 reinterpret_cast<int*>(&(navigation->transition_))))
285 return false; 285 return false;
286 // type_mask did not always exist in the written stream. As such, we 286 // type_mask did not always exist in the written stream. As such, we
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 321 }
322 322
323 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand( 323 bool BaseSessionService::RestoreSetTabExtensionAppIDCommand(
324 const SessionCommand& command, 324 const SessionCommand& command,
325 SessionID::id_type* tab_id, 325 SessionID::id_type* tab_id,
326 std::string* extension_app_id) { 326 std::string* extension_app_id) {
327 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); 327 scoped_ptr<Pickle> pickle(command.PayloadAsPickle());
328 if (!pickle.get()) 328 if (!pickle.get())
329 return false; 329 return false;
330 330
331 void* iterator = NULL; 331 PickleIterator iterator(*pickle);
332 return pickle->ReadInt(&iterator, tab_id) && 332 return pickle->ReadInt(&iterator, tab_id) &&
333 pickle->ReadString(&iterator, extension_app_id); 333 pickle->ReadString(&iterator, extension_app_id);
334 } 334 }
335 335
336 bool BaseSessionService::RestoreSetWindowAppNameCommand( 336 bool BaseSessionService::RestoreSetWindowAppNameCommand(
337 const SessionCommand& command, 337 const SessionCommand& command,
338 SessionID::id_type* window_id, 338 SessionID::id_type* window_id,
339 std::string* app_name) { 339 std::string* app_name) {
340 scoped_ptr<Pickle> pickle(command.PayloadAsPickle()); 340 scoped_ptr<Pickle> pickle(command.PayloadAsPickle());
341 if (!pickle.get()) 341 if (!pickle.get())
342 return false; 342 return false;
343 343
344 void* iterator = NULL; 344 PickleIterator iterator(*pickle);
345 return pickle->ReadInt(&iterator, window_id) && 345 return pickle->ReadInt(&iterator, window_id) &&
346 pickle->ReadString(&iterator, app_name); 346 pickle->ReadString(&iterator, app_name);
347 } 347 }
348 348
349 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { 349 bool BaseSessionService::ShouldTrackEntry(const GURL& url) {
350 // NOTE: Do not track print preview tab because re-opening that page will 350 // NOTE: Do not track print preview tab because re-opening that page will
351 // just display a non-functional print preview page. 351 // just display a non-functional print preview page.
352 return url.is_valid() && url != GURL(chrome::kChromeUIPrintURL); 352 return url.is_valid() && url != GURL(chrome::kChromeUIPrintURL);
353 } 353 }
354 354
(...skipping 29 matching lines...) Expand all
384 384
385 void BaseSessionService::ResetContentStateReadingMetrics() { 385 void BaseSessionService::ResetContentStateReadingMetrics() {
386 time_spent_reading_compressed_content_states = base::TimeDelta(); 386 time_spent_reading_compressed_content_states = base::TimeDelta();
387 } 387 }
388 388
389 void BaseSessionService::WriteContentStateReadingMetrics() { 389 void BaseSessionService::WriteContentStateReadingMetrics() {
390 UMA_HISTOGRAM_TIMES("SessionService.ReadingCompressedContentStates", 390 UMA_HISTOGRAM_TIMES("SessionService.ReadingCompressedContentStates",
391 time_spent_reading_compressed_content_states); 391 time_spent_reading_compressed_content_states);
392 ResetContentStateReadingMetrics(); 392 ResetContentStateReadingMetrics();
393 } 393 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/native_backend_kwallet_x.cc ('k') | chrome/browser/sessions/compress_data_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698