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

Side by Side Diff: components/sessions/core/tab_restore_service_helper.cc

Issue 1350653004: [sessions] Properly namespace recently-componentized TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 5 years, 3 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sessions/core/tab_restore_service_helper.h" 5 #include "components/sessions/core/tab_restore_service_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "components/sessions/core/live_tab.h" 13 #include "components/sessions/core/live_tab.h"
14 #include "components/sessions/core/tab_restore_service_client.h" 14 #include "components/sessions/core/tab_restore_service_client.h"
15 #include "components/sessions/core/tab_restore_service_delegate.h" 15 #include "components/sessions/core/tab_restore_service_delegate.h"
16 #include "components/sessions/core/tab_restore_service_observer.h" 16 #include "components/sessions/core/tab_restore_service_observer.h"
17 #include "components/sessions/serialized_navigation_entry.h" 17 #include "components/sessions/serialized_navigation_entry.h"
18 #include "components/sessions/session_types.h" 18 #include "components/sessions/session_types.h"
19 19
20 using sessions::LiveTab; 20 namespace sessions {
21 21
22 // TabRestoreServiceHelper::Observer ------------------------------------------- 22 // TabRestoreServiceHelper::Observer -------------------------------------------
23 23
24 TabRestoreServiceHelper::Observer::~Observer() {} 24 TabRestoreServiceHelper::Observer::~Observer() {}
25 25
26 void TabRestoreServiceHelper::Observer::OnClearEntries() {} 26 void TabRestoreServiceHelper::Observer::OnClearEntries() {}
27 27
28 void TabRestoreServiceHelper::Observer::OnRestoreEntryById( 28 void TabRestoreServiceHelper::Observer::OnRestoreEntryById(
29 SessionID::id_type id, 29 SessionID::id_type id,
30 Entries::const_iterator entry_iterator) { 30 Entries::const_iterator entry_iterator) {
31 } 31 }
32 32
33 void TabRestoreServiceHelper::Observer::OnAddEntry() {} 33 void TabRestoreServiceHelper::Observer::OnAddEntry() {}
34 34
35 // TabRestoreServiceHelper ----------------------------------------------------- 35 // TabRestoreServiceHelper -----------------------------------------------------
36 36
37 TabRestoreServiceHelper::TabRestoreServiceHelper( 37 TabRestoreServiceHelper::TabRestoreServiceHelper(
38 TabRestoreService* tab_restore_service, 38 TabRestoreService* tab_restore_service,
39 Observer* observer, 39 Observer* observer,
40 sessions::TabRestoreServiceClient* client, 40 TabRestoreServiceClient* client,
41 TabRestoreService::TimeFactory* time_factory) 41 TabRestoreService::TimeFactory* time_factory)
42 : tab_restore_service_(tab_restore_service), 42 : tab_restore_service_(tab_restore_service),
43 observer_(observer), 43 observer_(observer),
44 client_(client), 44 client_(client),
45 restoring_(false), 45 restoring_(false),
46 time_factory_(time_factory) { 46 time_factory_(time_factory) {
47 DCHECK(tab_restore_service_); 47 DCHECK(tab_restore_service_);
48 } 48 }
49 49
50 TabRestoreServiceHelper::~TabRestoreServiceHelper() { 50 TabRestoreServiceHelper::~TabRestoreServiceHelper() {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void TabRestoreServiceHelper::PopulateTab(Tab* tab, 362 void TabRestoreServiceHelper::PopulateTab(Tab* tab,
363 int index, 363 int index,
364 TabRestoreServiceDelegate* delegate, 364 TabRestoreServiceDelegate* delegate,
365 LiveTab* live_tab) { 365 LiveTab* live_tab) {
366 const int pending_index = live_tab->GetPendingEntryIndex(); 366 const int pending_index = live_tab->GetPendingEntryIndex();
367 int entry_count = live_tab->GetEntryCount(); 367 int entry_count = live_tab->GetEntryCount();
368 if (entry_count == 0 && pending_index == 0) 368 if (entry_count == 0 && pending_index == 0)
369 entry_count++; 369 entry_count++;
370 tab->navigations.resize(static_cast<int>(entry_count)); 370 tab->navigations.resize(static_cast<int>(entry_count));
371 for (int i = 0; i < entry_count; ++i) { 371 for (int i = 0; i < entry_count; ++i) {
372 sessions::SerializedNavigationEntry entry = 372 SerializedNavigationEntry entry = (i == pending_index)
373 (i == pending_index) ? live_tab->GetPendingEntry() 373 ? live_tab->GetPendingEntry()
374 : live_tab->GetEntryAtIndex(i); 374 : live_tab->GetEntryAtIndex(i);
375 tab->navigations[i] = entry; 375 tab->navigations[i] = entry;
376 } 376 }
377 tab->timestamp = TimeNow(); 377 tab->timestamp = TimeNow();
378 tab->current_navigation_index = live_tab->GetCurrentEntryIndex(); 378 tab->current_navigation_index = live_tab->GetCurrentEntryIndex();
379 if (tab->current_navigation_index == -1 && entry_count > 0) 379 if (tab->current_navigation_index == -1 && entry_count > 0)
380 tab->current_navigation_index = 0; 380 tab->current_navigation_index = 0;
381 tab->tabstrip_index = index; 381 tab->tabstrip_index = index;
382 382
383 tab->extension_app_id = client_->GetExtensionAppIDForTab(live_tab); 383 tab->extension_app_id = client_->GetExtensionAppIDForTab(live_tab);
384 384
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 Tab* tab = static_cast<Tab*>(entry); 526 Tab* tab = static_cast<Tab*>(entry);
527 if (tab->browser_id == old_id) 527 if (tab->browser_id == old_id)
528 tab->browser_id = new_id; 528 tab->browser_id = new_id;
529 } 529 }
530 } 530 }
531 } 531 }
532 532
533 base::Time TabRestoreServiceHelper::TimeNow() const { 533 base::Time TabRestoreServiceHelper::TimeNow() const {
534 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); 534 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now();
535 } 535 }
536
537 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/core/tab_restore_service_helper.h ('k') | components/sessions/core/tab_restore_service_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698