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

Side by Side Diff: ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.mm

Issue 2588733002: Upstream Chrome on iOS source code [9/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.h"
6
7 #include "base/strings/sys_string_conversions.h"
8 #import "ios/chrome/browser/tabs/tab.h"
9
10 TabModelSnapshot::TabModelSnapshot(TabModel* tabModel) {
11 for (Tab* tab in tabModel) {
12 _hashes.push_back(hashOfTheVisiblePropertiesOfATab(tab));
13 _tabs.push_back(base::WeakNSObject<Tab>(tab));
14 }
15 }
16
17 TabModelSnapshot::~TabModelSnapshot() {}
18
19 std::vector<size_t> const& TabModelSnapshot::hashes() const {
20 DCHECK_EQ(_tabs.size(), _hashes.size());
21 return _hashes;
22 }
23
24 std::vector<base::WeakNSObject<Tab>> const& TabModelSnapshot::tabs() const {
25 DCHECK_EQ(_tabs.size(), _hashes.size());
26 return _tabs;
27 }
28
29 size_t TabModelSnapshot::hashOfTheVisiblePropertiesOfATab(Tab* tab) {
30 DCHECK(tab);
31 std::stringstream ss;
32 // lastVisitedTimestamp is used as an approximation for whether the tab's
33 // snapshot changed.
34 ss << tab.tabId << std::endl
35 << base::SysNSStringToUTF8(tab.urlDisplayString) << std::endl
36 << std::hexfloat << tab.lastVisitedTimestamp << std::endl;
37 return std::hash<std::string>()(ss.str());
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698