summaryrefslogtreecommitdiffstats
path: root/chrome/test/sync/engine
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 21:48:04 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-09 21:48:04 +0000
commit18a79705d6958ee9255a1b6a71887b3d654865d0 (patch)
tree8462ccc9aede1574807abe5effed0dc7f1c6db6a /chrome/test/sync/engine
parent96e34671ec5233dac8398a6f32c9b0648a134f30 (diff)
downloadchromium_src-18a79705d6958ee9255a1b6a71887b3d654865d0.zip
chromium_src-18a79705d6958ee9255a1b6a71887b3d654865d0.tar.gz
chromium_src-18a79705d6958ee9255a1b6a71887b3d654865d0.tar.bz2
Make SyncerThread stop polling if an AUTH_INVALID response is parsed.
BUG=34396 TEST=SyncerTHreadWithSyncerTest.AuthInvalid Review URL: http://codereview.chromium.org/596007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/sync/engine')
-rwxr-xr-xchrome/test/sync/engine/mock_server_connection.cc36
-rwxr-xr-xchrome/test/sync/engine/mock_server_connection.h31
2 files changed, 48 insertions, 19 deletions
diff --git a/chrome/test/sync/engine/mock_server_connection.cc b/chrome/test/sync/engine/mock_server_connection.cc
index f424390..e3cb225 100755
--- a/chrome/test/sync/engine/mock_server_connection.cc
+++ b/chrome/test/sync/engine/mock_server_connection.cc
@@ -72,8 +72,9 @@ void MockConnectionManager::SetMidCommitObserver(
}
bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params,
- const string& path,
- const string& auth_token) {
+ const string& path,
+ const string& auth_token,
+ browser_sync::ScopedServerStatusWatcher* watcher) {
ClientToServerMessage post;
CHECK(post.ParseFromString(params->buffer_in));
client_stuck_ = post.sync_problem_detected();
@@ -125,11 +126,14 @@ bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params,
}
{
- AutoLock throttle_lock(throttle_lock_);
+ AutoLock lock(response_code_override_lock_);
if (throttling_) {
- response.set_error_code(ClientToServerResponse::THROTTLED);
- throttling_ = false;
+ response.set_error_code(ClientToServerResponse::THROTTLED);
+ throttling_ = false;
}
+
+ if (fail_with_auth_invalid_)
+ response.set_error_code(ClientToServerResponse::AUTH_INVALID);
}
response.SerializeToString(params->buffer_out);
@@ -408,9 +412,25 @@ const CommitMessage& MockConnectionManager::last_sent_commit() const {
}
void MockConnectionManager::ThrottleNextRequest(
- ThrottleRequestVisitor* visitor) {
- AutoLock lock(throttle_lock_);
+ ResponseCodeOverrideRequestor* visitor) {
+ AutoLock lock(response_code_override_lock_);
throttling_ = true;
if (visitor)
- visitor->VisitAtomically();
+ visitor->OnOverrideComplete();
+}
+
+void MockConnectionManager::FailWithAuthInvalid(
+ ResponseCodeOverrideRequestor* visitor) {
+ AutoLock lock(response_code_override_lock_);
+ fail_with_auth_invalid_ = true;
+ if (visitor)
+ visitor->OnOverrideComplete();
}
+
+void MockConnectionManager::StopFailingWithAuthInvalid(
+ ResponseCodeOverrideRequestor* visitor) {
+ AutoLock lock(response_code_override_lock_);
+ fail_with_auth_invalid_ = false;
+ if (visitor)
+ visitor->OnOverrideComplete();
+} \ No newline at end of file
diff --git a/chrome/test/sync/engine/mock_server_connection.h b/chrome/test/sync/engine/mock_server_connection.h
index 852ff07..adb7177 100755
--- a/chrome/test/sync/engine/mock_server_connection.h
+++ b/chrome/test/sync/engine/mock_server_connection.h
@@ -39,8 +39,9 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager {
// Overridden ServerConnectionManager functions.
virtual bool PostBufferToPath(const PostBufferParams*,
- const string& path,
- const string& auth_token);
+ const string& path,
+ const string& auth_token,
+ browser_sync::ScopedServerStatusWatcher* watcher);
virtual bool IsServerReachable();
virtual bool IsUserAuthenticated();
@@ -116,15 +117,17 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager {
void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; }
// A visitor class to allow a test to change some monitoring state atomically
- // with the action of throttling requests (for example, so you can say
- // "ThrottleNextRequest, and assert no more requests are made once throttling
- // is in effect" in one step.
- class ThrottleRequestVisitor {
+ // with the action of overriding the response codes sent back to the Syncer
+ // (for example, so you can say "ThrottleNextRequest, and assert no more
+ // requests are made once throttling is in effect" in one step.
+ class ResponseCodeOverrideRequestor {
public:
- // Called with throttle parameter lock acquired.
- virtual void VisitAtomically() = 0;
+ // Called with response_code_override_lock_ acquired.
+ virtual void OnOverrideComplete() = 0;
};
- void ThrottleNextRequest(ThrottleRequestVisitor* visitor);
+ void ThrottleNextRequest(ResponseCodeOverrideRequestor* visitor);
+ void FailWithAuthInvalid(ResponseCodeOverrideRequestor* visitor);
+ void StopFailingWithAuthInvalid(ResponseCodeOverrideRequestor* visitor);
void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; }
// Simple inspectors.
@@ -222,9 +225,15 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager {
std::string valid_auth_token_;
// Whether we are faking a server mandating clients to throttle requests.
- // Protected by |throttle_lock_|.
+ // Protected by |response_code_override_lock_|.
bool throttling_;
- Lock throttle_lock_;
+
+ // Whether we are failing all requests by returning
+ // ClientToServerResponse::AUTH_INVALID.
+ // Protected by |response_code_override_lock_|.
+ bool fail_with_auth_invalid_;
+
+ Lock response_code_override_lock_;
// True if we are only accepting GetUpdatesCallerInfo::PERIODIC requests.
bool fail_non_periodic_get_updates_;