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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 340055: String cleanup in sync code (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer.cc » ('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) 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 #include "chrome/browser/sync/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 private: 128 private:
129 AddressWatchTaskParams* const params_; 129 AddressWatchTaskParams* const params_;
130 DISALLOW_COPY_AND_ASSIGN(AddressWatchTask); 130 DISALLOW_COPY_AND_ASSIGN(AddressWatchTask);
131 }; 131 };
132 132
133 namespace sync_api { 133 namespace sync_api {
134 class ModelSafeWorkerBridge; 134 class ModelSafeWorkerBridge;
135 135
136 static const PSTR_CHAR kBookmarkSyncUserSettingsDatabase[] = 136 static const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] =
137 PSTR("BookmarkSyncSettings.sqlite3"); 137 FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3");
138 static const PSTR_CHAR kDefaultNameForNewNodes[] = PSTR(" "); 138 static const PSTR_CHAR kDefaultNameForNewNodes[] = PSTR(" ");
139 139
140 // The list of names which are reserved for use by the server. 140 // The list of names which are reserved for use by the server.
141 static const char16* kForbiddenServerNames[] = 141 static const char16* kForbiddenServerNames[] =
142 { STRING16(""), STRING16("."), STRING16("..") }; 142 { STRING16(""), STRING16("."), STRING16("..") };
143 143
144 ////////////////////////////////////////////////////////////////////////// 144 //////////////////////////////////////////////////////////////////////////
145 // Static helper functions. 145 // Static helper functions.
146 146
147 // Helper function to look up the int64 metahandle of an object given the ID 147 // Helper function to look up the int64 metahandle of an object given the ID
(...skipping 16 matching lines...) Expand all
164 if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0) 164 if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0)
165 return true; 165 return true;
166 } 166 }
167 return false; 167 return false;
168 } 168 }
169 169
170 static bool EndsWithSpace(const string16& string) { 170 static bool EndsWithSpace(const string16& string) {
171 return !string.empty() && *string.rbegin() == ' '; 171 return !string.empty() && *string.rbegin() == ' ';
172 } 172 }
173 173
174 static inline void String16ToPathString(const sync_char16 *in,
175 PathString *out) {
176 string16 in_str(in);
177 #if defined(OS_WIN)
178 out->assign(in_str);
179 #else
180 UTF16ToUTF8(in_str.c_str(), in_str.length(), out);
181 #endif
182 }
183
184 static inline void PathStringToString16(const PathString& in, string16* out) {
185 #if defined(OS_WIN)
186 out->assign(in);
187 #else
188 UTF8ToUTF16(in.c_str(), in.length(), out);
189 #endif
190 }
191
192 // When taking a name from the syncapi, append a space if it matches the 174 // When taking a name from the syncapi, append a space if it matches the
193 // pattern of a server-illegal name followed by zero or more spaces. 175 // pattern of a server-illegal name followed by zero or more spaces.
194 static void SyncAPINameToServerName(const sync_char16 *sync_api_name, 176 static void SyncAPINameToServerName(const sync_char16 *sync_api_name,
195 PathString* out) { 177 PathString* out) {
196 String16ToPathString(sync_api_name, out); 178 *out = UTF16ToUTF8(sync_api_name);
197 string16 sync_api_name_str(sync_api_name); 179 string16 sync_api_name_str(sync_api_name);
198 if (IsNameServerIllegalAfterTrimming(sync_api_name_str)) 180 if (IsNameServerIllegalAfterTrimming(sync_api_name_str))
199 out->append(PSTR(" ")); 181 out->append(PSTR(" "));
200 } 182 }
201 183
202 // In the reverse direction, if a server name matches the pattern of a 184 // In the reverse direction, if a server name matches the pattern of a
203 // server-illegal name followed by one or more spaces, remove the trailing 185 // server-illegal name followed by one or more spaces, remove the trailing
204 // space. 186 // space.
205 static void ServerNameToSyncAPIName(const PathString& server_name, 187 static void ServerNameToSyncAPIName(const PathString& server_name,
206 string16*out) { 188 string16*out) {
207 string16 server_name_str; 189 string16 server_name_str(UTF8ToUTF16(server_name));
208 PathStringToString16(server_name, &server_name_str);
209 if (IsNameServerIllegalAfterTrimming(server_name_str) && 190 if (IsNameServerIllegalAfterTrimming(server_name_str) &&
210 EndsWithSpace(server_name_str)) 191 EndsWithSpace(server_name_str))
211 out->assign(server_name_str, 0, server_name_str.size() - 1); 192 out->assign(server_name_str, 0, server_name_str.size() - 1);
212 else 193 else
213 out->assign(server_name_str); 194 out->assign(server_name_str);
214 } 195 }
215 196
216 // A UserShare encapsulates the syncable pieces that represent an authenticated 197 // A UserShare encapsulates the syncable pieces that represent an authenticated
217 // user and their data (share). 198 // user and their data (share).
218 // This encompasses all pieces required to build transaction objects on the 199 // This encompasses all pieces required to build transaction objects on the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 246
266 const sync_char16* BaseNode::GetTitle() const { 247 const sync_char16* BaseNode::GetTitle() const {
267 // Store the string in data_ so that the returned pointer is valid. 248 // Store the string in data_ so that the returned pointer is valid.
268 ServerNameToSyncAPIName(GetEntry()->GetName().non_unique_value(), 249 ServerNameToSyncAPIName(GetEntry()->GetName().non_unique_value(),
269 &data_->title); 250 &data_->title);
270 return data_->title.c_str(); 251 return data_->title.c_str();
271 } 252 }
272 253
273 const sync_char16* BaseNode::GetURL() const { 254 const sync_char16* BaseNode::GetURL() const {
274 // Store the string in data_ so that the returned pointer is valid. 255 // Store the string in data_ so that the returned pointer is valid.
275 PathStringToString16(GetEntry()->Get(syncable::BOOKMARK_URL), &data_->url); 256 data_->url = UTF8ToUTF16(GetEntry()->Get(syncable::BOOKMARK_URL));
276 return data_->url.c_str(); 257 return data_->url.c_str();
277 } 258 }
278 259
279 const int64* BaseNode::GetChildIds(size_t* child_count) const { 260 const int64* BaseNode::GetChildIds(size_t* child_count) const {
280 DCHECK(child_count); 261 DCHECK(child_count);
281 Directory* dir = GetTransaction()->GetLookup(); 262 Directory* dir = GetTransaction()->GetLookup();
282 dir->GetChildHandles(GetTransaction()->GetWrappedTrans(), 263 dir->GetChildHandles(GetTransaction()->GetWrappedTrans(),
283 GetEntry()->Get(syncable::ID), &data_->child_handles); 264 GetEntry()->Get(syncable::ID), &data_->child_handles);
284 265
285 *child_count = data_->child_handles.size(); 266 *child_count = data_->child_handles.size();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 db_name.MakeNoncollidingForEntry(transaction_->GetWrappedTrans(), 331 db_name.MakeNoncollidingForEntry(transaction_->GetWrappedTrans(),
351 entry_->Get(syncable::PARENT_ID), entry_); 332 entry_->Get(syncable::PARENT_ID), entry_);
352 333
353 syncable::Name new_name = syncable::Name::FromDBNameAndSyncName(db_name, 334 syncable::Name new_name = syncable::Name::FromDBNameAndSyncName(db_name,
354 sync_name); 335 sync_name);
355 entry_->PutName(new_name); 336 entry_->PutName(new_name);
356 MarkForSyncing(); 337 MarkForSyncing();
357 } 338 }
358 339
359 void WriteNode::SetURL(const sync_char16* url) { 340 void WriteNode::SetURL(const sync_char16* url) {
360 PathString url_string; 341 PathString url_string(UTF16ToUTF8(url));
361 String16ToPathString(url, &url_string);
362 if (url_string == entry_->Get(syncable::BOOKMARK_URL)) 342 if (url_string == entry_->Get(syncable::BOOKMARK_URL))
363 return; // Skip redundant changes. 343 return; // Skip redundant changes.
364 344
365 entry_->Put(syncable::BOOKMARK_URL, url_string); 345 entry_->Put(syncable::BOOKMARK_URL, url_string);
366 MarkForSyncing(); 346 MarkForSyncing();
367 } 347 }
368 348
369 void WriteNode::SetExternalId(int64 id) { 349 void WriteNode::SetExternalId(int64 id) {
370 if (GetExternalId() != id) 350 if (GetExternalId() != id)
371 entry_->Put(syncable::LOCAL_EXTERNAL_ID, id); 351 entry_->Put(syncable::LOCAL_EXTERNAL_ID, id);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 const syncable::Entry* ReadNode::GetEntry() const { 516 const syncable::Entry* ReadNode::GetEntry() const {
537 return entry_; 517 return entry_;
538 } 518 }
539 519
540 const BaseTransaction* ReadNode::GetTransaction() const { 520 const BaseTransaction* ReadNode::GetTransaction() const {
541 return transaction_; 521 return transaction_;
542 } 522 }
543 523
544 bool ReadNode::InitByTagLookup(const sync_char16* tag) { 524 bool ReadNode::InitByTagLookup(const sync_char16* tag) {
545 DCHECK(!entry_) << "Init called twice"; 525 DCHECK(!entry_) << "Init called twice";
546 PathString tag_string; 526 PathString tag_string(UTF16ToUTF8(tag));
547 String16ToPathString(tag, &tag_string);
548 if (tag_string.empty()) 527 if (tag_string.empty())
549 return false; 528 return false;
550 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans(); 529 syncable::BaseTransaction* trans = transaction_->GetWrappedTrans();
551 entry_ = new syncable::Entry(trans, syncable::GET_BY_TAG, tag_string); 530 entry_ = new syncable::Entry(trans, syncable::GET_BY_TAG, tag_string);
552 if (!entry_->good()) 531 if (!entry_->good())
553 return false; 532 return false;
554 if (entry_->Get(syncable::IS_DEL)) 533 if (entry_->Get(syncable::IS_DEL))
555 return false; 534 return false;
556 LOG_IF(WARNING, !entry_->Get(syncable::IS_BOOKMARK_OBJECT)) 535 LOG_IF(WARNING, !entry_->Get(syncable::IS_BOOKMARK_OBJECT))
557 << "SyncAPI InitByTagLookup referencing non-bookmark object."; 536 << "SyncAPI InitByTagLookup referencing non-bookmark object.";
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 command_channel_(0), 674 command_channel_(0),
696 auth_problem_(AUTH_PROBLEM_NONE), 675 auth_problem_(AUTH_PROBLEM_NONE),
697 sync_manager_(sync_manager), 676 sync_manager_(sync_manager),
698 address_watch_thread_("SyncEngine_AddressWatcher"), 677 address_watch_thread_("SyncEngine_AddressWatcher"),
699 notification_pending_(false), 678 notification_pending_(false),
700 initialized_(false) { 679 initialized_(false) {
701 } 680 }
702 681
703 ~SyncInternal() { } 682 ~SyncInternal() { }
704 683
705 bool Init(const PathString& database_location, 684 bool Init(const FilePath& database_location,
706 const std::string& sync_server_and_path, 685 const std::string& sync_server_and_path,
707 int port, 686 int port,
708 const char* gaia_service_id, 687 const char* gaia_service_id,
709 const char* gaia_source, 688 const char* gaia_source,
710 bool use_ssl, 689 bool use_ssl,
711 HttpPostProviderFactory* post_factory, 690 HttpPostProviderFactory* post_factory,
712 HttpPostProviderFactory* auth_post_factory, 691 HttpPostProviderFactory* auth_post_factory,
713 ModelSafeWorkerInterface* model_safe_worker, 692 ModelSafeWorkerInterface* model_safe_worker,
714 bool attempt_last_user_authentication, 693 bool attempt_last_user_authentication,
715 const char* user_agent); 694 const char* user_agent);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // meaning we are ready to accept changes. Protected by initialized_mutex_ 913 // meaning we are ready to accept changes. Protected by initialized_mutex_
935 // as it can get read/set by both the SyncerThread and the AuthWatcherThread. 914 // as it can get read/set by both the SyncerThread and the AuthWatcherThread.
936 bool initialized_; 915 bool initialized_;
937 mutable Lock initialized_mutex_; 916 mutable Lock initialized_mutex_;
938 }; 917 };
939 918
940 SyncManager::SyncManager() { 919 SyncManager::SyncManager() {
941 data_ = new SyncInternal(this); 920 data_ = new SyncInternal(this);
942 } 921 }
943 922
944 bool SyncManager::Init(const sync_char16* database_location, 923 bool SyncManager::Init(const FilePath& database_location,
945 const char* sync_server_and_path, 924 const char* sync_server_and_path,
946 int sync_server_port, 925 int sync_server_port,
947 const char* gaia_service_id, 926 const char* gaia_service_id,
948 const char* gaia_source, 927 const char* gaia_source,
949 bool use_ssl, 928 bool use_ssl,
950 HttpPostProviderFactory* post_factory, 929 HttpPostProviderFactory* post_factory,
951 HttpPostProviderFactory* auth_post_factory, 930 HttpPostProviderFactory* auth_post_factory,
952 ModelSafeWorkerInterface* model_safe_worker, 931 ModelSafeWorkerInterface* model_safe_worker,
953 bool attempt_last_user_authentication, 932 bool attempt_last_user_authentication,
954 const char* user_agent) { 933 const char* user_agent) {
955 DCHECK(database_location);
956 DCHECK(post_factory); 934 DCHECK(post_factory);
957 935
958 PathString db_path;
959 String16ToPathString(database_location, &db_path);
960 string server_string(sync_server_and_path); 936 string server_string(sync_server_and_path);
961 return data_->Init(db_path, 937 return data_->Init(database_location,
962 server_string, 938 server_string,
963 sync_server_port, 939 sync_server_port,
964 gaia_service_id, 940 gaia_service_id,
965 gaia_source, 941 gaia_source,
966 use_ssl, 942 use_ssl,
967 post_factory, 943 post_factory,
968 auth_post_factory, 944 auth_post_factory,
969 model_safe_worker, 945 model_safe_worker,
970 attempt_last_user_authentication, 946 attempt_last_user_authentication,
971 user_agent); 947 user_agent);
972 } 948 }
973 949
974 void SyncManager::Authenticate(const char* username, const char* password) { 950 void SyncManager::Authenticate(const char* username, const char* password) {
975 data_->Authenticate(std::string(username), std::string(password)); 951 data_->Authenticate(std::string(username), std::string(password));
976 } 952 }
977 953
978 const char* SyncManager::GetAuthenticatedUsername() { 954 const char* SyncManager::GetAuthenticatedUsername() {
979 if (!data_) 955 if (!data_)
980 return NULL; 956 return NULL;
981 return data_->GetAuthenticatedUsername(); 957 return data_->GetAuthenticatedUsername();
982 } 958 }
983 959
984 const char* SyncManager::SyncInternal::GetAuthenticatedUsername() { 960 const char* SyncManager::SyncInternal::GetAuthenticatedUsername() {
985 cached_auth_watcher_email_ = browser_sync::ToUTF8( 961 cached_auth_watcher_email_ = username_for_share();
986 username_for_share()).get_string();
987 return cached_auth_watcher_email_.c_str(); 962 return cached_auth_watcher_email_.c_str();
988 } 963 }
989 964
990 bool SyncManager::SyncInternal::Init( 965 bool SyncManager::SyncInternal::Init(
991 const PathString& database_location, 966 const FilePath& database_location,
992 const std::string& sync_server_and_path, 967 const std::string& sync_server_and_path,
993 int port, 968 int port,
994 const char* gaia_service_id, 969 const char* gaia_service_id,
995 const char* gaia_source, 970 const char* gaia_source,
996 bool use_ssl, HttpPostProviderFactory* post_factory, 971 bool use_ssl, HttpPostProviderFactory* post_factory,
997 HttpPostProviderFactory* auth_post_factory, 972 HttpPostProviderFactory* auth_post_factory,
998 ModelSafeWorkerInterface* model_safe_worker, 973 ModelSafeWorkerInterface* model_safe_worker,
999 bool attempt_last_user_authentication, 974 bool attempt_last_user_authentication,
1000 const char* user_agent) { 975 const char* user_agent) {
1001 976
1002 // Set up UserSettings, creating the db if necessary. We need this to 977 // Set up UserSettings, creating the db if necessary. We need this to
1003 // instantiate a URLFactory to give to the Syncer. 978 // instantiate a URLFactory to give to the Syncer.
1004 PathString settings_db_file = AppendSlash(database_location) + 979 FilePath settings_db_file =
1005 kBookmarkSyncUserSettingsDatabase; 980 database_location.Append(FilePath(kBookmarkSyncUserSettingsDatabase));
1006 user_settings_.reset(new UserSettings()); 981 user_settings_.reset(new UserSettings());
1007 if (!user_settings_->Init(settings_db_file)) 982 if (!user_settings_->Init(settings_db_file))
1008 return false; 983 return false;
1009 984
1010 share_.dir_manager.reset(new DirectoryManager(database_location)); 985 share_.dir_manager.reset(new DirectoryManager(database_location));
1011 986
1012 string client_id = user_settings_->GetClientId(); 987 string client_id = user_settings_->GetClientId();
1013 connection_manager_.reset(new SyncAPIServerConnectionManager( 988 connection_manager_.reset(new SyncAPIServerConnectionManager(
1014 sync_server_and_path, port, use_ssl, user_agent, client_id)); 989 sync_server_and_path, port, use_ssl, user_agent, client_id));
1015 990
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 initialized_ = true; 1071 initialized_ = true;
1097 } 1072 }
1098 1073
1099 // Notify that initialization is complete. 1074 // Notify that initialization is complete.
1100 if (observer_) 1075 if (observer_)
1101 observer_->OnInitializationComplete(); 1076 observer_->OnInitializationComplete();
1102 } 1077 }
1103 1078
1104 void SyncManager::SyncInternal::Authenticate(const std::string& username, 1079 void SyncManager::SyncInternal::Authenticate(const std::string& username,
1105 const std::string& password) { 1080 const std::string& password) {
1106 DCHECK(username_for_share().empty() || 1081 DCHECK(username_for_share().empty() || username == username_for_share())
1107 (username == browser_sync::ToUTF8(username_for_share()).get_string()))
1108 << "Username change from valid username detected"; 1082 << "Username change from valid username detected";
1109 if (allstatus()->status().authenticated) 1083 if (allstatus()->status().authenticated)
1110 return; 1084 return;
1111 if (password.empty()) { 1085 if (password.empty()) {
1112 // TODO(timsteele): Seems like this shouldn't be needed, but auth_watcher 1086 // TODO(timsteele): Seems like this shouldn't be needed, but auth_watcher
1113 // currently drops blank password attempts on the floor and doesn't update 1087 // currently drops blank password attempts on the floor and doesn't update
1114 // state; it only LOGs an error in this case. We want to make sure we set 1088 // state; it only LOGs an error in this case. We want to make sure we set
1115 // our AuthProblem state to denote an error. 1089 // our AuthProblem state to denote an error.
1116 RaiseAuthNeededEvent(); 1090 RaiseAuthNeededEvent();
1117 } 1091 }
1118 auth_watcher()->Authenticate(username, password, true); 1092 auth_watcher()->Authenticate(username, password, true);
1119 } 1093 }
1120 1094
1121 void SyncManager::SyncInternal::AuthenticateForLastKnownUser() { 1095 void SyncManager::SyncInternal::AuthenticateForLastKnownUser() {
1122 std::string username; 1096 std::string username;
1123 std::string auth_token; 1097 std::string auth_token;
1124 if (!(auth_watcher()->settings()->GetLastUserAndServiceToken( 1098 if (!(auth_watcher()->settings()->GetLastUserAndServiceToken(
1125 SYNC_SERVICE_NAME, &username, &auth_token))) { 1099 SYNC_SERVICE_NAME, &username, &auth_token))) {
1126 RaiseAuthNeededEvent(); 1100 RaiseAuthNeededEvent();
1127 return; 1101 return;
1128 } 1102 }
1129 1103
1130 browser_sync::ToPathString s(username); 1104 share_.authenticated_name = username;
1131 if (s.good()) {
1132 share_.authenticated_name = s.get_string16();
1133 } else {
1134 RaiseAuthNeededEvent();
1135 return;
1136 }
1137 1105
1138 // We optimize by opening the directory before the "fresh" authentication 1106 // We optimize by opening the directory before the "fresh" authentication
1139 // attempt completes so that we can immediately begin processing changes. 1107 // attempt completes so that we can immediately begin processing changes.
1140 if (!dir_manager()->Open(username_for_share())) { 1108 if (!dir_manager()->Open(username_for_share())) {
1141 DCHECK(false) << "Had last known user but could not open directory"; 1109 DCHECK(false) << "Had last known user but could not open directory";
1142 return; 1110 return;
1143 } 1111 }
1144 1112
1145 // Set the sync data type so that the server only sends us bookmarks 1113 // Set the sync data type so that the server only sends us bookmarks
1146 // changes. 1114 // changes.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 if (event.what_happened == AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START) 1410 if (event.what_happened == AuthWatcherEvent::AUTHENTICATION_ATTEMPT_START)
1443 return; 1411 return;
1444 // We clear our last auth problem cache on new auth watcher events, and only 1412 // We clear our last auth problem cache on new auth watcher events, and only
1445 // set it to indicate a problem state for certain AuthWatcherEvent types. 1413 // set it to indicate a problem state for certain AuthWatcherEvent types.
1446 auth_problem_ = AUTH_PROBLEM_NONE; 1414 auth_problem_ = AUTH_PROBLEM_NONE;
1447 switch (event.what_happened) { 1415 switch (event.what_happened) {
1448 case AuthWatcherEvent::AUTH_SUCCEEDED: 1416 case AuthWatcherEvent::AUTH_SUCCEEDED:
1449 // We now know the supplied username and password were valid. If this 1417 // We now know the supplied username and password were valid. If this
1450 // wasn't the first sync, authenticated_name should already be assigned. 1418 // wasn't the first sync, authenticated_name should already be assigned.
1451 if (username_for_share().empty()) { 1419 if (username_for_share().empty()) {
1452 browser_sync::ToPathString s(event.user_email); 1420 share_.authenticated_name = event.user_email;
1453 if (s.good())
1454 share_.authenticated_name = s.get_string16();
1455 } 1421 }
1456 1422
1457 DCHECK(LowerCaseEqualsASCII(browser_sync::ToUTF8( 1423 DCHECK(LowerCaseEqualsASCII(username_for_share(),
1458 username_for_share()).get_string(),
1459 StringToLowerASCII(event.user_email).c_str())) 1424 StringToLowerASCII(event.user_email).c_str()))
1460 << "username_for_share= " 1425 << "username_for_share= " << username_for_share()
1461 << browser_sync::ToUTF8(username_for_share())
1462 << ", event.user_email= " << event.user_email; 1426 << ", event.user_email= " << event.user_email;
1463 1427
1464 if (observer_) 1428 if (observer_)
1465 observer_->OnAuthProblem(AUTH_PROBLEM_NONE); 1429 observer_->OnAuthProblem(AUTH_PROBLEM_NONE);
1466 1430
1467 // Hook up the DirectoryChangeEvent listener, HandleChangeEvent. 1431 // Hook up the DirectoryChangeEvent listener, HandleChangeEvent.
1468 { 1432 {
1469 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); 1433 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1470 if (!lookup.good()) { 1434 if (!lookup.good()) {
1471 DCHECK(false) << "ScopedDirLookup creation failed; unable to hook " 1435 DCHECK(false) << "ScopedDirLookup creation failed; unable to hook "
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 lookup->SaveChanges(); 1493 lookup->SaveChanges();
1530 } 1494 }
1531 1495
1532 void SyncManager::SetupForTestMode(const sync_char16* test_username) { 1496 void SyncManager::SetupForTestMode(const sync_char16* test_username) {
1533 DCHECK(data_) << "SetupForTestMode requires initialization"; 1497 DCHECK(data_) << "SetupForTestMode requires initialization";
1534 data_->SetupForTestMode(test_username); 1498 data_->SetupForTestMode(test_username);
1535 } 1499 }
1536 1500
1537 void SyncManager::SyncInternal::SetupForTestMode( 1501 void SyncManager::SyncInternal::SetupForTestMode(
1538 const sync_char16* test_username) { 1502 const sync_char16* test_username) {
1539 String16ToPathString(test_username, &share_.authenticated_name); 1503 share_.authenticated_name = UTF16ToUTF8(test_username);
1540 1504
1541 if (!dir_manager()->Open(username_for_share())) 1505 if (!dir_manager()->Open(username_for_share()))
1542 DCHECK(false) << "Could not open directory when running in test mode"; 1506 DCHECK(false) << "Could not open directory when running in test mode";
1543 1507
1544 // Hook up the DirectoryChangeEvent listener, HandleChangeEvent. 1508 // Hook up the DirectoryChangeEvent listener, HandleChangeEvent.
1545 { 1509 {
1546 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); 1510 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1547 if (!lookup.good()) { 1511 if (!lookup.good()) {
1548 DCHECK(false) << "ScopedDirLookup creation failed; unable to hook " 1512 DCHECK(false) << "ScopedDirLookup creation failed; unable to hook "
1549 << "up directory change event listener!"; 1513 << "up directory change event listener!";
(...skipping 19 matching lines...) Expand all
1569 BaseTransaction::~BaseTransaction() { 1533 BaseTransaction::~BaseTransaction() {
1570 delete lookup_; 1534 delete lookup_;
1571 } 1535 }
1572 1536
1573 UserShare* SyncManager::GetUserShare() const { 1537 UserShare* SyncManager::GetUserShare() const {
1574 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 1538 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
1575 return data_->GetUserShare(); 1539 return data_->GetUserShare();
1576 } 1540 }
1577 1541
1578 } // namespace sync_api 1542 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698