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

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

Issue 2810193002: [ObjC ARC] Converts ios/chrome/browser/ui/tab_switcher:tab_switcher to ARC. (Closed)
Patch Set: comment Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 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 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 #import "ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.h" 5 #import "ios/chrome/browser/ui/tab_switcher/tab_model_snapshot.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #import "ios/chrome/browser/tabs/tab.h" 8 #import "ios/chrome/browser/tabs/tab.h"
9 #import "ios/chrome/browser/tabs/tab_model.h"
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
9 14
10 TabModelSnapshot::TabModelSnapshot(TabModel* tabModel) { 15 TabModelSnapshot::TabModelSnapshot(TabModel* tabModel) {
11 for (Tab* tab in tabModel) { 16 for (Tab* tab in tabModel) {
12 _hashes.push_back(hashOfTheVisiblePropertiesOfATab(tab)); 17 _hashes.push_back(hashOfTheVisiblePropertiesOfATab(tab));
13 _tabs.push_back(base::WeakNSObject<Tab>(tab)); 18 _tabs.push_back(base::WeakNSObject<Tab>(tab));
14 } 19 }
15 } 20 }
16 21
17 TabModelSnapshot::~TabModelSnapshot() {} 22 TabModelSnapshot::~TabModelSnapshot() {}
18 23
19 std::vector<size_t> const& TabModelSnapshot::hashes() const { 24 std::vector<size_t> const& TabModelSnapshot::hashes() const {
20 DCHECK_EQ(_tabs.size(), _hashes.size()); 25 DCHECK_EQ(_tabs.size(), _hashes.size());
21 return _hashes; 26 return _hashes;
22 } 27 }
23 28
24 std::vector<base::WeakNSObject<Tab>> const& TabModelSnapshot::tabs() const { 29 std::vector<base::WeakNSObject<Tab>> const& TabModelSnapshot::tabs() const {
25 DCHECK_EQ(_tabs.size(), _hashes.size()); 30 DCHECK_EQ(_tabs.size(), _hashes.size());
26 return _tabs; 31 return _tabs;
27 } 32 }
28 33
29 size_t TabModelSnapshot::hashOfTheVisiblePropertiesOfATab(Tab* tab) { 34 size_t TabModelSnapshot::hashOfTheVisiblePropertiesOfATab(Tab* tab) {
30 DCHECK(tab); 35 DCHECK(tab);
31 std::stringstream ss; 36 std::stringstream ss;
32 // lastVisitedTimestamp is used as an approximation for whether the tab's 37 // lastVisitedTimestamp is used as an approximation for whether the tab's
33 // snapshot changed. 38 // snapshot changed.
34 ss << tab.tabId << std::endl 39 ss << base::SysNSStringToUTF8(tab.tabId) << std::endl
35 << base::SysNSStringToUTF8(tab.urlDisplayString) << std::endl 40 << base::SysNSStringToUTF8(tab.urlDisplayString) << std::endl
36 << std::hexfloat << tab.lastVisitedTimestamp << std::endl; 41 << std::hexfloat << tab.lastVisitedTimestamp << std::endl;
37 return std::hash<std::string>()(ss.str()); 42 return std::hash<std::string>()(ss.str());
38 } 43 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tab_switcher/BUILD.gn ('k') | ios/chrome/browser/ui/tab_switcher/tab_switcher_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698