| OLD | NEW |
| 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/sync/test/integration/sessions_helper.h" | 5 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 class TabEventHandler : public browser_sync::LocalSessionEventHandler { | 130 class TabEventHandler : public browser_sync::LocalSessionEventHandler { |
| 131 public: | 131 public: |
| 132 TabEventHandler() : weak_factory_(this) { | 132 TabEventHandler() : weak_factory_(this) { |
| 133 base::MessageLoop::current()->PostDelayedTask( | 133 base::MessageLoop::current()->PostDelayedTask( |
| 134 FROM_HERE, | 134 FROM_HERE, |
| 135 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()), | 135 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr()), |
| 136 TestTimeouts::action_max_timeout()); | 136 TestTimeouts::action_max_timeout()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void OnLocalTabModified( | 139 void OnLocalTabModified( |
| 140 browser_sync::SyncedTabDelegate* modified_tab) override { | 140 browser_sync::SyncedTabDelegate* modified_tab) override { |
| 141 // Unwind to ensure SessionsSyncManager has processed the event. | 141 // Unwind to ensure SessionsSyncManager has processed the event. |
| 142 base::MessageLoop::current()->PostTask( | 142 base::MessageLoop::current()->PostTask( |
| 143 FROM_HERE, | 143 FROM_HERE, |
| 144 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); | 144 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); |
| 145 } | 145 } |
| 146 | 146 |
| 147 virtual void OnFaviconPageUrlsUpdated( | 147 void OnFaviconPageUrlsUpdated( |
| 148 const std::set<GURL>& updated_page_urls) override { | 148 const std::set<GURL>& updated_page_urls) override { |
| 149 // Unwind to ensure SessionsSyncManager has processed the event. | 149 // Unwind to ensure SessionsSyncManager has processed the event. |
| 150 base::MessageLoop::current()->PostTask( | 150 base::MessageLoop::current()->PostTask( |
| 151 FROM_HERE, | 151 FROM_HERE, |
| 152 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); | 152 base::Bind(&TabEventHandler::QuitLoop, weak_factory_.GetWeakPtr())); |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 void QuitLoop() { | 156 void QuitLoop() { |
| 157 base::MessageLoop::current()->Quit(); | 157 base::MessageLoop::current()->Quit(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return true; | 360 return true; |
| 361 } | 361 } |
| 362 | 362 |
| 363 namespace { | 363 namespace { |
| 364 | 364 |
| 365 // Helper class used in the implementation of AwaitCheckForeignSessionsAgainst. | 365 // Helper class used in the implementation of AwaitCheckForeignSessionsAgainst. |
| 366 class CheckForeignSessionsChecker : public MultiClientStatusChangeChecker { | 366 class CheckForeignSessionsChecker : public MultiClientStatusChangeChecker { |
| 367 public: | 367 public: |
| 368 CheckForeignSessionsChecker(int index, | 368 CheckForeignSessionsChecker(int index, |
| 369 const std::vector<ScopedWindowMap>& windows); | 369 const std::vector<ScopedWindowMap>& windows); |
| 370 virtual ~CheckForeignSessionsChecker(); | 370 ~CheckForeignSessionsChecker() override; |
| 371 | 371 |
| 372 virtual bool IsExitConditionSatisfied() override; | 372 bool IsExitConditionSatisfied() override; |
| 373 virtual std::string GetDebugMessage() const override; | 373 std::string GetDebugMessage() const override; |
| 374 |
| 374 private: | 375 private: |
| 375 int index_; | 376 int index_; |
| 376 const std::vector<ScopedWindowMap>& windows_; | 377 const std::vector<ScopedWindowMap>& windows_; |
| 377 }; | 378 }; |
| 378 | 379 |
| 379 CheckForeignSessionsChecker::CheckForeignSessionsChecker( | 380 CheckForeignSessionsChecker::CheckForeignSessionsChecker( |
| 380 int index, const std::vector<ScopedWindowMap>& windows) | 381 int index, const std::vector<ScopedWindowMap>& windows) |
| 381 : MultiClientStatusChangeChecker( | 382 : MultiClientStatusChangeChecker( |
| 382 sync_datatype_helper::test()->GetSyncServices()), | 383 sync_datatype_helper::test()->GetSyncServices()), |
| 383 index_(index), | 384 index_(index), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 402 return !checker.TimedOut(); | 403 return !checker.TimedOut(); |
| 403 } | 404 } |
| 404 | 405 |
| 405 void DeleteForeignSession(int index, std::string session_tag) { | 406 void DeleteForeignSession(int index, std::string session_tag) { |
| 406 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 407 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 407 test()->GetProfile(index))-> | 408 test()->GetProfile(index))-> |
| 408 GetOpenTabsUIDelegate()->DeleteForeignSession(session_tag); | 409 GetOpenTabsUIDelegate()->DeleteForeignSession(session_tag); |
| 409 } | 410 } |
| 410 | 411 |
| 411 } // namespace sessions_helper | 412 } // namespace sessions_helper |
| OLD | NEW |