| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" | 5 #include "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/scoped_nsobject.h" | |
| 12 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 15 #include "components/sync/driver/sync_service.h" | 14 #include "components/sync/driver/sync_service.h" |
| 16 #include "components/sync_sessions/open_tabs_ui_delegate.h" | 15 #include "components/sync_sessions/open_tabs_ui_delegate.h" |
| 17 #include "ios/chrome/browser/sync/sync_setup_service.h" | 16 #include "ios/chrome/browser/sync/sync_setup_service.h" |
| 18 | 17 |
| 18 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 19 #error "This file requires ARC support." |
| 20 #endif |
| 21 |
| 19 namespace { | 22 namespace { |
| 20 | 23 |
| 21 // Comparator function for sorting the sessions_ vector so that the most | 24 // Comparator function for sorting the sessions_ vector so that the most |
| 22 // recently used sessions are at the beginning. | 25 // recently used sessions are at the beginning. |
| 23 bool SortSessionsByTime( | 26 bool SortSessionsByTime( |
| 24 std::unique_ptr<const synced_sessions::DistantSession>& a, | 27 std::unique_ptr<const synced_sessions::DistantSession>& a, |
| 25 std::unique_ptr<const synced_sessions::DistantSession>& b) { | 28 std::unique_ptr<const synced_sessions::DistantSession>& b) { |
| 26 return a->modified_time > b->modified_time; | 29 return a->modified_time > b->modified_time; |
| 27 } | 30 } |
| 28 | 31 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 DCHECK_LE(index, GetSessionCount()); | 170 DCHECK_LE(index, GetSessionCount()); |
| 168 sessions_.erase(sessions_.begin() + index); | 171 sessions_.erase(sessions_.begin() + index); |
| 169 } | 172 } |
| 170 | 173 |
| 171 void SyncedSessions::AddDistantSessionForTest( | 174 void SyncedSessions::AddDistantSessionForTest( |
| 172 std::unique_ptr<const DistantSession> distant_session) { | 175 std::unique_ptr<const DistantSession> distant_session) { |
| 173 sessions_.push_back(std::move(distant_session)); | 176 sessions_.push_back(std::move(distant_session)); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // synced_sessions namespace | 179 } // synced_sessions namespace |
| OLD | NEW |