| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // AuthWatcher watches authentication events and user open and close | 5 // AuthWatcher watches authentication events and user open and close |
| 6 // events and accordingly opens and closes shares. | 6 // events and accordingly opens and closes shares. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
| 9 #define CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 9 #define CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/atomicops.h" | 14 #include "base/atomicops.h" |
| 15 #include "base/gtest_prod_util.h" |
| 15 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
| 16 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
| 17 #include "base/thread.h" | 18 #include "base/thread.h" |
| 18 #include "chrome/browser/sync/protocol/service_constants.h" | 19 #include "chrome/browser/sync/protocol/service_constants.h" |
| 19 #include "chrome/browser/sync/util/sync_types.h" | 20 #include "chrome/browser/sync/util/sync_types.h" |
| 20 #include "chrome/common/deprecated/event_sys.h" | 21 #include "chrome/common/deprecated/event_sys.h" |
| 21 #include "chrome/common/net/gaia/gaia_authenticator.h" | 22 #include "chrome/common/net/gaia/gaia_authenticator.h" |
| 22 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST | |
| 23 | 23 |
| 24 namespace syncable { | 24 namespace syncable { |
| 25 struct DirectoryManagerEvent; | 25 struct DirectoryManagerEvent; |
| 26 class DirectoryManager; | 26 class DirectoryManager; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace browser_sync { | 29 namespace browser_sync { |
| 30 | 30 |
| 31 class AuthWatcher; | 31 class AuthWatcher; |
| 32 class ServerConnectionManager; | 32 class ServerConnectionManager; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // The mother-class of Authentication for the sync backend. Handles both gaia | 72 // The mother-class of Authentication for the sync backend. Handles both gaia |
| 73 // and sync service authentication via asynchronous Authenticate* methods, | 73 // and sync service authentication via asynchronous Authenticate* methods, |
| 74 // raising AuthWatcherEvents on success/failure. The implementation currently | 74 // raising AuthWatcherEvents on success/failure. The implementation currently |
| 75 // runs its own backend thread for the actual auth processing, which means | 75 // runs its own backend thread for the actual auth processing, which means |
| 76 // the AuthWatcherEvents can be raised on a different thread than the one that | 76 // the AuthWatcherEvents can be raised on a different thread than the one that |
| 77 // invoked authentication. | 77 // invoked authentication. |
| 78 class AuthWatcher : public base::RefCountedThreadSafe<AuthWatcher> { | 78 class AuthWatcher : public base::RefCountedThreadSafe<AuthWatcher> { |
| 79 friend class AuthWatcherTest; | 79 friend class AuthWatcherTest; |
| 80 FRIEND_TEST(AuthWatcherTest, Construction); | 80 FRIEND_TEST_ALL_PREFIXES(AuthWatcherTest, Construction); |
| 81 public: | 81 public: |
| 82 // Normal progression is local -> gaia -> token. | 82 // Normal progression is local -> gaia -> token. |
| 83 enum Status { LOCALLY_AUTHENTICATED, GAIA_AUTHENTICATED, NOT_AUTHENTICATED }; | 83 enum Status { LOCALLY_AUTHENTICATED, GAIA_AUTHENTICATED, NOT_AUTHENTICATED }; |
| 84 typedef syncable::DirectoryManagerEvent DirectoryManagerEvent; | 84 typedef syncable::DirectoryManagerEvent DirectoryManagerEvent; |
| 85 typedef syncable::DirectoryManager DirectoryManager; | 85 typedef syncable::DirectoryManager DirectoryManager; |
| 86 | 86 |
| 87 AuthWatcher(DirectoryManager* dirman, | 87 AuthWatcher(DirectoryManager* dirman, |
| 88 ServerConnectionManager* scm, | 88 ServerConnectionManager* scm, |
| 89 const std::string& user_agent, | 89 const std::string& user_agent, |
| 90 const std::string& service_id, | 90 const std::string& service_id, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 base::Thread auth_backend_thread_; | 210 base::Thread auth_backend_thread_; |
| 211 | 211 |
| 212 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; | 212 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; |
| 213 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); | 213 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace browser_sync | 216 } // namespace browser_sync |
| 217 | 217 |
| 218 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 218 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
| OLD | NEW |