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

Side by Side Diff: chrome/test/sync/engine/mock_connection_manager.cc

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/sync/engine/test_directory_setter_upper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Mock ServerConnectionManager class for use in client regression tests. 5 // Mock ServerConnectionManager class for use in client regression tests.
6 6
7 #include "chrome/test/sync/engine/mock_connection_manager.h" 7 #include "chrome/test/sync/engine/mock_connection_manager.h"
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/tracked.h"
12 #include "chrome/browser/sync/engine/syncer_proto_util.h" 13 #include "chrome/browser/sync/engine/syncer_proto_util.h"
13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
14 #include "chrome/test/sync/engine/test_id_factory.h" 15 #include "chrome/test/sync/engine/test_id_factory.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using browser_sync::HttpResponse; 18 using browser_sync::HttpResponse;
18 using browser_sync::ServerConnectionManager; 19 using browser_sync::ServerConnectionManager;
19 using browser_sync::ServerConnectionEventListener; 20 using browser_sync::ServerConnectionEventListener;
20 using browser_sync::ServerConnectionEvent; 21 using browser_sync::ServerConnectionEvent;
21 using browser_sync::SyncerProtoUtil; 22 using browser_sync::SyncerProtoUtil;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 response.Clear(); 91 response.Clear();
91 92
92 ScopedDirLookup directory(directory_manager_, directory_name_); 93 ScopedDirLookup directory(directory_manager_, directory_name_);
93 // For any non-AUTHENTICATE requests, a valid directory should be set up. 94 // For any non-AUTHENTICATE requests, a valid directory should be set up.
94 // If the Directory's locked when we do this, it's a problem as in normal 95 // If the Directory's locked when we do this, it's a problem as in normal
95 // use this function could take a while to return because it accesses the 96 // use this function could take a while to return because it accesses the
96 // network. As we can't test this we do the next best thing and hang here 97 // network. As we can't test this we do the next best thing and hang here
97 // when there's an issue. 98 // when there's an issue.
98 if (post.message_contents() != ClientToServerMessage::AUTHENTICATE) { 99 if (post.message_contents() != ClientToServerMessage::AUTHENTICATE) {
99 CHECK(directory.good()); 100 CHECK(directory.good());
100 WriteTransaction wt(directory, syncable::UNITTEST, __FILE__, __LINE__); 101 WriteTransaction wt(directory, syncable::UNITTEST, FROM_HERE);
101 } 102 }
102 103
103 if (fail_next_postbuffer_) { 104 if (fail_next_postbuffer_) {
104 fail_next_postbuffer_ = false; 105 fail_next_postbuffer_ = false;
105 return false; 106 return false;
106 } 107 }
107 108
108 if (!server_reachable_) { 109 if (!server_reachable_) {
109 params->response->server_status = HttpResponse::CONNECTION_UNAVAILABLE; 110 params->response->server_status = HttpResponse::CONNECTION_UNAVAILABLE;
110 return false; 111 return false;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 ServerConnectionEvent(server_status_, server_reachable_)); 613 ServerConnectionEvent(server_status_, server_reachable_));
613 } 614 }
614 615
615 void MockConnectionManager::SetServerNotReachable() { 616 void MockConnectionManager::SetServerNotReachable() {
616 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE; 617 server_status_ = HttpResponse::CONNECTION_UNAVAILABLE;
617 server_reachable_ = false; 618 server_reachable_ = false;
618 619
619 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent, 620 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent,
620 ServerConnectionEvent(server_status_, server_reachable_)); 621 ServerConnectionEvent(server_status_, server_reachable_));
621 } 622 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/sync/engine/test_directory_setter_upper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698