diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 18:18:33 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 18:18:33 +0000 |
commit | 36d4ad5008ee38a8ab0ddad065e4ec46ffff5d0a (patch) | |
tree | bf59fd4fde5f3052ff09588a42bc734bd0b89090 | |
parent | c6e01dc7a346439ae64a00f9acd204025e17a218 (diff) | |
download | chromium_src-36d4ad5008ee38a8ab0ddad065e4ec46ffff5d0a.zip chromium_src-36d4ad5008ee38a8ab0ddad065e4ec46ffff5d0a.tar.gz chromium_src-36d4ad5008ee38a8ab0ddad065e4ec46ffff5d0a.tar.bz2 |
Fix compiling of sync on linux.
Review URL: http://codereview.chromium.org/211019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26835 0039d316-1c4b-4281-b951-d872f2087c98
40 files changed, 158 insertions, 164 deletions
diff --git a/chrome/browser/sync/engine/all_status.cc b/chrome/browser/sync/engine/all_status.cc index 1c8c5ed..2cdd4fe 100644 --- a/chrome/browser/sync/engine/all_status.cc +++ b/chrome/browser/sync/engine/all_status.cc @@ -30,8 +30,8 @@ static const int kBackoffRandomizationFactor = 2; const char* AllStatus::GetSyncStatusString(SyncStatus icon) { const char* strings[] = {"OFFLINE", "OFFLINE_UNSYNCED", "SYNCING", "READY", "CONFLICT", "OFFLINE_UNUSABLE"}; - COMPILE_ASSERT(ARRAYSIZE(strings) == ICON_STATUS_COUNT, enum_indexed_array); - if (icon < 0 || icon >= ARRAYSIZE(strings)) + COMPILE_ASSERT(arraysize(strings) == ICON_STATUS_COUNT, enum_indexed_array); + if (icon < 0 || icon >= static_cast<SyncStatus>(arraysize(strings))) LOG(FATAL) << "Illegal Icon State:" << icon; return strings[icon]; } @@ -42,8 +42,8 @@ static const AllStatus::Status init_status = static const AllStatusEvent shutdown_event = { AllStatusEvent::SHUTDOWN, init_status }; -AllStatus::AllStatus() : channel_(new Channel(shutdown_event)), - status_(init_status) { +AllStatus::AllStatus() : status_(init_status), + channel_(new Channel(shutdown_event)) { status_.initial_sync_ended = true; status_.notifications_enabled = false; } diff --git a/chrome/browser/sync/engine/auth_watcher.cc b/chrome/browser/sync/engine/auth_watcher.cc index 0c999dd..f46cbe9 100644 --- a/chrome/browser/sync/engine/auth_watcher.cc +++ b/chrome/browser/sync/engine/auth_watcher.cc @@ -50,16 +50,16 @@ AuthWatcher::AuthWatcher(DirectoryManager* dirman, UserSettings* user_settings, GaiaAuthenticator* gaia_auth, TalkMediator* talk_mediator) - : dirman_(dirman), + : gaia_(gaia_auth), + dirman_(dirman), scm_(scm), allstatus_(allstatus), status_(NOT_AUTHENTICATED), + user_settings_(user_settings), + talk_mediator_(talk_mediator), thread_handle_valid_(false), authenticating_now_(false), - current_attempt_trigger_(AuthWatcherEvent::USER_INITIATED), - user_settings_(user_settings), - gaia_(gaia_auth), - talk_mediator_(talk_mediator) { + current_attempt_trigger_(AuthWatcherEvent::USER_INITIATED) { connmgr_hookup_.reset( NewEventListenerHookup(scm->channel(), this, &AuthWatcher::HandleServerConnectionEvent)); @@ -190,7 +190,7 @@ bool AuthWatcher::AuthenticateWithToken(const string& gaia_email, bool AuthWatcher::AuthenticateLocally(string email) { user_settings_->GetEmailForSignin(&email); - if (file_util::PathExists(dirman_->GetSyncDataDatabasePath())) { + if (file_util::PathExists(FilePath(dirman_->GetSyncDataDatabasePath()))) { gaia_->SetUsername(email); status_ = LOCALLY_AUTHENTICATED; user_settings_->SwitchUser(email); diff --git a/chrome/browser/sync/engine/auth_watcher.h b/chrome/browser/sync/engine/auth_watcher.h index b0dba61..3759011 100644 --- a/chrome/browser/sync/engine/auth_watcher.h +++ b/chrome/browser/sync/engine/auth_watcher.h @@ -71,7 +71,6 @@ class AuthWatcher { enum Status { LOCALLY_AUTHENTICATED, GAIA_AUTHENTICATED, NOT_AUTHENTICATED }; typedef syncable::DirectoryManagerEvent DirectoryManagerEvent; typedef syncable::DirectoryManager DirectoryManager; - typedef TalkMediator TalkMediator; AuthWatcher(DirectoryManager* dirman, ServerConnectionManager* scm, diff --git a/chrome/browser/sync/engine/build_and_process_conflict_sets_command.cc b/chrome/browser/sync/engine/build_and_process_conflict_sets_command.cc index c4f8ce3..a57f9ed 100644 --- a/chrome/browser/sync/engine/build_and_process_conflict_sets_command.cc +++ b/chrome/browser/sync/engine/build_and_process_conflict_sets_command.cc @@ -60,7 +60,7 @@ bool BuildAndProcessConflictSetsCommand::ProcessSingleDirectionConflictSets( CHECK(conflict_set->size() >= 2); // We scan the set to see if it consists of changes of only one type. ConflictSet::const_iterator i; - int unsynced_count = 0, unapplied_count = 0; + size_t unsynced_count = 0, unapplied_count = 0; for (i = conflict_set->begin(); i != conflict_set->end(); ++i) { syncable::Entry entry(trans, syncable::GET_BY_ID, *i); CHECK(entry.good()); @@ -120,7 +120,6 @@ bool RollbackEntry(syncable::WriteTransaction* trans, syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, backup->ref(syncable::META_HANDLE)); CHECK(entry.good()); - bool was_del = entry.Get(syncable::IS_DEL); if (!entry.Put(syncable::IS_DEL, backup->ref(syncable::IS_DEL))) return false; diff --git a/chrome/browser/sync/engine/build_and_process_conflict_sets_command.h b/chrome/browser/sync/engine/build_and_process_conflict_sets_command.h index 706748b..e0fed74 100644 --- a/chrome/browser/sync/engine/build_and_process_conflict_sets_command.h +++ b/chrome/browser/sync/engine/build_and_process_conflict_sets_command.h @@ -39,9 +39,8 @@ class BuildAndProcessConflictSetsCommand : public ModelChangingSyncerCommand { syncable::WriteTransaction* trans, const std::vector<syncable::Id>* const update_set, SyncerSession* const session); - void BuildAndProcessConflictSetsCommand::BuildConflictSets( - syncable::BaseTransaction* trans, - ConflictResolutionView* view); + void BuildConflictSets(syncable::BaseTransaction* trans, + ConflictResolutionView* view); void MergeSetsForNameClash(syncable::BaseTransaction* trans, syncable::Entry* entry, diff --git a/chrome/browser/sync/engine/conflict_resolver.cc b/chrome/browser/sync/engine/conflict_resolver.cc index 27ed93f..c6f5234 100644 --- a/chrome/browser/sync/engine/conflict_resolver.cc +++ b/chrome/browser/sync/engine/conflict_resolver.cc @@ -65,7 +65,7 @@ Name FindNewName(BaseTransaction* trans, const SyncName& original_name) { const PathString name = original_name.value(); // 255 is defined in our spec. - const int allowed_length = kSyncProtocolMaxNameLengthBytes; + const size_t allowed_length = kSyncProtocolMaxNameLengthBytes; // TODO(sync): How do we get length on other platforms? The limit is // checked in java on the server, so it's not the number of glyphs its the // number of 16 bit characters in the UTF-16 representation. @@ -664,8 +664,8 @@ bool ConflictResolver::ResolveSimpleConflicts(const ScopedDirLookup& dir, case NO_SYNC_PROGRESS: { int conflict_count = (simple_conflict_count_map_[id] += 2); - bool stuck = LogAndSignalIfConflictStuck(&trans, conflict_count, - &id, &id + 1, view); + LogAndSignalIfConflictStuck(&trans, conflict_count, + &id, &id + 1, view); break; } case SYNC_PROGRESS: @@ -724,9 +724,9 @@ bool ConflictResolver::ResolveConflicts(const ScopedDirLookup& dir, rv = true; } SyncerStatus status(session); - bool stuck = LogAndSignalIfConflictStuck(&trans, conflict_count, - conflict_set->begin(), - conflict_set->end(), view); + LogAndSignalIfConflictStuck(&trans, conflict_count, + conflict_set->begin(), + conflict_set->end(), view); } if (rv) { // This code means we don't signal that syncing is stuck when any conflict diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.cc b/chrome/browser/sync/engine/net/gaia_authenticator.cc index 382048f..49a40d8 100644 --- a/chrome/browser/sync/engine/net/gaia_authenticator.cc +++ b/chrome/browser/sync/engine/net/gaia_authenticator.cc @@ -30,7 +30,7 @@ bool SplitStringIntoKeyValues(const string& line, values->clear(); // find the key string - int end_key_pos = line.find_first_of(key_value_delimiter); + size_t end_key_pos = line.find_first_of(key_value_delimiter); if (end_key_pos == string::npos) { DLOG(INFO) << "cannot parse key from line: " << line; return false; // no key @@ -39,7 +39,7 @@ bool SplitStringIntoKeyValues(const string& line, // find the values string string remains(line, end_key_pos, line.size() - end_key_pos); - int begin_values_pos = remains.find_first_not_of(key_value_delimiter); + size_t begin_values_pos = remains.find_first_not_of(key_value_delimiter); if (begin_values_pos == string::npos) { DLOG(INFO) << "cannot parse value from line: " << line; return false; // no value @@ -92,9 +92,9 @@ GaiaAuthenticator::GaiaAuthenticator(const string& user_agent, service_id_(service_id), gaia_url_(gaia_url), request_count_(0), - early_auth_attempt_count_(0), delay_(0), - next_allowed_auth_attempt_time_(0) { + next_allowed_auth_attempt_time_(0), + early_auth_attempt_count_(0) { GaiaAuthEvent done = { GaiaAuthEvent::GAIA_AUTHENTICATOR_DESTROYED, None, this }; channel_ = new Channel(done); diff --git a/chrome/browser/sync/engine/net/server_connection_manager.cc b/chrome/browser/sync/engine/net/server_connection_manager.cc index 3e60d2d..c2fadac 100644 --- a/chrome/browser/sync/engine/net/server_connection_manager.cc +++ b/chrome/browser/sync/engine/net/server_connection_manager.cc @@ -143,16 +143,20 @@ struct WatchServerStatus { ServerConnectionManager::ServerConnectionManager( const string& server, int port, bool use_ssl, const string& user_agent, const string& client_id) - : sync_server_(server), sync_server_port_(port), - channel_(new Channel(shutdown_event)), - server_status_(HttpResponse::NONE), server_reachable_(false), - client_id_(client_id), use_ssl_(use_ssl), + : sync_server_(server), + sync_server_port_(port), + client_id_(client_id), user_agent_(user_agent), - platform_(new PlatformMembers(user_agent)), - reset_count_(0), error_count_(0), - terminate_all_io_(false), + use_ssl_(use_ssl), proto_sync_path_(kSyncServerSyncPath), - get_time_path_(kSyncServerGetTimePath) { + get_time_path_(kSyncServerGetTimePath), + error_count_(0), + channel_(new Channel(shutdown_event)), + server_status_(HttpResponse::NONE), + server_reachable_(false), + platform_(new PlatformMembers(user_agent)), + reset_count_(0), + terminate_all_io_(false) { } ServerConnectionManager::~ServerConnectionManager() { diff --git a/chrome/browser/sync/engine/process_commit_response_command.cc b/chrome/browser/sync/engine/process_commit_response_command.cc index 379a292..3deec6d 100644 --- a/chrome/browser/sync/engine/process_commit_response_command.cc +++ b/chrome/browser/sync/engine/process_commit_response_command.cc @@ -103,7 +103,6 @@ void ProcessCommitResponseCommand::ModelChangingExecuteImpl( bool over_quota = false; set<syncable::Id> conflicting_new_folder_ids; set<syncable::Id> deleted_folders; - bool truncated_commit_logged = false; { // Scope for WriteTransaction. WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__); for (int i = 0; i < cr.entryresponse_size(); i++) { diff --git a/chrome/browser/sync/engine/process_updates_command.cc b/chrome/browser/sync/engine/process_updates_command.cc index 31c204b..9d6ce2d 100644 --- a/chrome/browser/sync/engine/process_updates_command.cc +++ b/chrome/browser/sync/engine/process_updates_command.cc @@ -92,6 +92,9 @@ void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncerSession* session) { if (update.sync_timestamp() > new_timestamp) new_timestamp = update.sync_timestamp(); break; + default: + NOTREACHED(); + break; } } diff --git a/chrome/browser/sync/engine/sync_cycle_state.h b/chrome/browser/sync/engine/sync_cycle_state.h index 375ca1f..0a27fbf 100644 --- a/chrome/browser/sync/engine/sync_cycle_state.h +++ b/chrome/browser/sync/engine/sync_cycle_state.h @@ -46,8 +46,8 @@ class SyncCycleState { conflicts_resolved_(false), items_committed_(false), over_quota_(false), - dirty_(true), - timestamp_dirty_(false) {} + timestamp_dirty_(false), + dirty_(true) {} void set_update_response(const ClientToServerResponse& update_response) { update_response_.CopyFrom(update_response); diff --git a/chrome/browser/sync/engine/sync_process_state.cc b/chrome/browser/sync/engine/sync_process_state.cc index 369a109..6e2e1ad 100644 --- a/chrome/browser/sync/engine/sync_process_state.cc +++ b/chrome/browser/sync/engine/sync_process_state.cc @@ -22,12 +22,12 @@ using std::vector; namespace browser_sync { SyncProcessState::SyncProcessState(const SyncProcessState& counts) - : account_name_(counts.account_name_), + : connection_manager_(counts.connection_manager_), + account_name_(counts.account_name_), dirman_(counts.dirman_), - syncer_event_channel_(counts.syncer_event_channel_), - connection_manager_(counts.connection_manager_), resolver_(counts.resolver_), - model_safe_worker_(counts.model_safe_worker_) { + model_safe_worker_(counts.model_safe_worker_), + syncer_event_channel_(counts.syncer_event_channel_) { *this = counts; } @@ -37,21 +37,23 @@ SyncProcessState::SyncProcessState(syncable::DirectoryManager* dirman, ConflictResolver* const resolver, SyncerEventChannel* syncer_event_channel, ModelSafeWorker* model_safe_worker) - : account_name_(account_name), - dirman_(dirman), - syncer_event_channel_(syncer_event_channel), + : num_sync_cycles_(0), + silenced_until_(0), connection_manager_(connection_manager), - model_safe_worker_(model_safe_worker), + account_name_(account_name), + dirman_(dirman), resolver_(resolver), - syncer_stuck_(false), - num_sync_cycles_(0), - silenced_until_(0), + model_safe_worker_(model_safe_worker), + syncer_event_channel_(syncer_event_channel), error_rate_(0), current_sync_timestamp_(0), servers_latest_timestamp_(0), + syncing_(false), + invalid_store_(false), + syncer_stuck_(false), error_commits_(0), - stalled_commits_(0), conflicting_commits_(0), + stalled_commits_(0), consecutive_problem_get_updates_(0), consecutive_problem_commits_(0), consecutive_transient_error_commits_(0), @@ -59,8 +61,7 @@ SyncProcessState::SyncProcessState(syncable::DirectoryManager* dirman, successful_commits_(0), dirty_(false), auth_dirty_(false), - auth_failed_(false), - invalid_store_(false) { + auth_failed_(false) { syncable::ScopedDirLookup dir(dirman_, account_name_); // The directory must be good here. diff --git a/chrome/browser/sync/engine/sync_process_state.h b/chrome/browser/sync/engine/sync_process_state.h index eeb0cef..528fb45 100644 --- a/chrome/browser/sync/engine/sync_process_state.h +++ b/chrome/browser/sync/engine/sync_process_state.h @@ -289,21 +289,23 @@ class SyncProcessState { private: // For testing. SyncProcessState() - : account_name_(PSTR("")), - dirman_(NULL), - syncer_event_channel_(NULL), + : num_sync_cycles_(0), + silenced_until_(0), connection_manager_(NULL), - model_safe_worker_(NULL), + account_name_(PSTR("")), + dirman_(NULL), resolver_(NULL), - syncer_stuck_(false), - num_sync_cycles_(0), - silenced_until_(0), + model_safe_worker_(NULL), + syncer_event_channel_(NULL), error_rate_(0), current_sync_timestamp_(0), servers_latest_timestamp_(0), + syncing_(false), + invalid_store_(false), + syncer_stuck_(false), error_commits_(0), - stalled_commits_(0), conflicting_commits_(0), + stalled_commits_(0), consecutive_problem_get_updates_(0), consecutive_problem_commits_(0), consecutive_transient_error_commits_(0), @@ -311,9 +313,7 @@ class SyncProcessState { successful_commits_(0), dirty_(false), auth_dirty_(false), - auth_failed_(false), - syncing_(false), - invalid_store_(false) {} + auth_failed_(false) {} ServerConnectionManager* connection_manager_; const PathString account_name_; diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index 386a1e4..f1ca43d 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -90,8 +90,8 @@ struct ThreadParams { void* AddressWatchThread(void* arg) { NameCurrentThreadForDebugging("SyncEngine_AddressWatcher"); LOG(INFO) << "starting the address watch thread"; - const ThreadParams* const params = reinterpret_cast<const ThreadParams*>(arg); #if defined(OS_WIN) + const ThreadParams* const params = reinterpret_cast<const ThreadParams*>(arg); OVERLAPPED overlapped = {0}; overlapped.hEvent = CreateEvent(NULL, FALSE, TRUE, NULL); HANDLE file; @@ -156,7 +156,7 @@ static int64 IdToMetahandle(syncable::BaseTransaction* trans, // also illegal, but are not considered here. static bool IsNameServerIllegalAfterTrimming(const string16& name) { size_t untrimmed_count = name.find_last_not_of(' ') + 1; - for (int i = 0; i < arraysize(kForbiddenServerNames); ++i) { + for (size_t i = 0; i < arraysize(kForbiddenServerNames); ++i) { if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0) return true; } @@ -1022,7 +1022,9 @@ bool SyncManager::SyncInternal::Init( address_watch_params_.conn_mgr = connection_manager(); address_watch_thread_ = CreatePThread(AddressWatchThread, &address_watch_params_); +#if defined(OS_WIN) DCHECK(NULL != address_watch_thread_); +#endif // Hand over the bridged POST factory to be owned by the connection // dir_manager. diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc index 33aa14d..49f7c3c 100644 --- a/chrome/browser/sync/engine/syncer_proto_util.cc +++ b/chrome/browser/sync/engine/syncer_proto_util.cc @@ -161,6 +161,9 @@ bool SyncerProtoUtil::PostClientToServerMessage(ClientToServerMessage* msg, session->set_silenced_until(time(0) + kSyncDelayAfterThrottled); rv = false; break; + default: + NOTREACHED(); + break; } } else if (session->connection_manager()->IsServerReachable()) { diff --git a/chrome/browser/sync/engine/syncer_status.h b/chrome/browser/sync/engine/syncer_status.h index 8da52a8..8301b56 100644 --- a/chrome/browser/sync/engine/syncer_status.h +++ b/chrome/browser/sync/engine/syncer_status.h @@ -27,8 +27,8 @@ class SyncerSession; class SyncerStatus { public: SyncerStatus(SyncCycleState* cycle_state, SyncProcessState* state) - : sync_process_state_(state), - sync_cycle_state_(cycle_state){} + : sync_cycle_state_(cycle_state), + sync_process_state_(state) {} explicit SyncerStatus(SyncerSession* s); ~SyncerStatus(); diff --git a/chrome/browser/sync/engine/syncer_thread.cc b/chrome/browser/sync/engine/syncer_thread.cc index e27437b..a53ab93 100644 --- a/chrome/browser/sync/engine/syncer_thread.cc +++ b/chrome/browser/sync/engine/syncer_thread.cc @@ -127,18 +127,27 @@ SyncerThread::SyncerThread( ServerConnectionManager* connection_manager, AllStatus* all_status, ModelSafeWorker* model_safe_worker) - : dirman_(mgr), scm_(connection_manager), - syncer_(NULL), syncer_events_(NULL), thread_running_(false), + : stop_syncer_thread_(false), + thread_running_(false), + connected_(false), + p2p_authenticated_(false), + p2p_subscribed_(false), + client_command_hookup_(NULL), + conn_mgr_hookup_(NULL), + allstatus_(all_status), + syncer_(NULL), + dirman_(mgr), + scm_(connection_manager), syncer_short_poll_interval_seconds_(kDefaultShortPollIntervalSeconds), syncer_long_poll_interval_seconds_(kDefaultLongPollIntervalSeconds), syncer_polling_interval_(kDefaultShortPollIntervalSeconds), syncer_max_interval_(kDefaultMaxPollIntervalMs), - stop_syncer_thread_(false), connected_(false), conn_mgr_hookup_(NULL), - p2p_authenticated_(false), p2p_subscribed_(false), - allstatus_(all_status), talk_mediator_hookup_(NULL), - command_channel_(command_channel), directory_manager_hookup_(NULL), + talk_mediator_hookup_(NULL), + command_channel_(command_channel), + directory_manager_hookup_(NULL), + syncer_events_(NULL), model_safe_worker_(model_safe_worker), - client_command_hookup_(NULL), disable_idle_detection_(false) { + disable_idle_detection_(false) { SyncerEvent shutdown = { SyncerEvent::SHUTDOWN_USE_WITH_CARE }; syncer_event_channel_.reset(new SyncerEventChannel(shutdown)); diff --git a/chrome/browser/sync/engine/syncer_util.cc b/chrome/browser/sync/engine/syncer_util.cc index e3bca85..8897480 100644 --- a/chrome/browser/sync/engine/syncer_util.cc +++ b/chrome/browser/sync/engine/syncer_util.cc @@ -299,7 +299,6 @@ UpdateAttemptResponse SyncerUtil::AttemptToUpdateEntryWithoutMerge( } } - int64 old_version = entry->Get(BASE_VERSION); SyncerUtil::UpdateLocalDataFromServerData(trans, entry); return SUCCESS; diff --git a/chrome/browser/sync/engine/update_applicator.cc b/chrome/browser/sync/engine/update_applicator.cc index 59ea303..6001c4e 100644 --- a/chrome/browser/sync/engine/update_applicator.cc +++ b/chrome/browser/sync/engine/update_applicator.cc @@ -61,6 +61,9 @@ bool UpdateApplicator::AttemptOneApplication( pointer_++; blocked_ids_.push_back(entry.Get(syncable::ID)); break; + default: + NOTREACHED(); + break; } LOG(INFO) << "Apply Status for " << entry.Get(syncable::META_HANDLE) << " is " << updateResponse; diff --git a/chrome/browser/sync/notifier/base/string.cc b/chrome/browser/sync/notifier/base/string.cc index 4c441f8..49ede9d 100644 --- a/chrome/browser/sync/notifier/base/string.cc +++ b/chrome/browser/sync/notifier/base/string.cc @@ -16,7 +16,9 @@ #include "talk/base/logging.h" #include "talk/base/stringencode.h" +#ifdef OS_WIN using base::snprintf; +#endif namespace notifier { @@ -278,7 +280,11 @@ std::string DoubleToString(double d) { std::string UIntToString(uint32 i) { char buf[80]; +#ifdef OS_LINUX + snprintf(buf, sizeof(buf), "%u", i); +#else snprintf(buf, sizeof(buf), "%lu", i); +#endif return std::string(buf); } diff --git a/chrome/browser/sync/notifier/base/task_pump.cc b/chrome/browser/sync/notifier/base/task_pump.cc index 0053d7a..f220063 100644 --- a/chrome/browser/sync/notifier/base/task_pump.cc +++ b/chrome/browser/sync/notifier/base/task_pump.cc @@ -17,7 +17,6 @@ TaskPump::TaskPump() : timeout_change_count_(0), posted_(false) { void TaskPump::OnMessage(talk_base::Message* msg) { posted_ = false; - int initial_count = timeout_change_count_; // If a task timed out, ensure that it is not blocked, so it will be deleted. // This may result in a WakeTasks if a task is timed out. diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc index dfcdf7a..cf30d07 100644 --- a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc +++ b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc @@ -23,7 +23,7 @@ namespace buzz { static const int kGaiaAuthTimeoutMs = 30 * 1000; // 30 sec // Warning, this is externed. -GaiaServer buzz::g_gaia_server; +GaiaServer g_gaia_server; /////////////////////////////////////////////////////////////////////////////// // GaiaAuth::WorkerThread diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc index 68cc56b..d693fb0 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.cc +++ b/chrome/browser/sync/syncable/directory_backing_store.cc @@ -8,8 +8,6 @@ #ifdef OS_MACOSX #include <CoreFoundation/CoreFoundation.h> -#elif defined(OS_LINUX) -#include <glib.h> #endif #include <string> @@ -24,6 +22,12 @@ #include "chrome/browser/sync/util/query_helpers.h" #include "third_party/sqlite/preprocessed/sqlite3.h" +// Sometimes threads contend on the DB lock itself, especially when one thread +// is calling SaveChanges. In the worst case scenario, the user can put his +// laptop to sleep during db contention, and wake up the laptop days later, so +// infinity seems like the best choice here. +const int kDirectoryBackingStoreBusyTimeoutMs = std::numeric_limits<int>::max(); + // If sizeof(time_t) != sizeof(int32) we need to alter or expand the sqlite // datatype. COMPILE_ASSERT(sizeof(time_t) == sizeof(int32), time_t_is_not_int32); @@ -39,6 +43,7 @@ static const string::size_type kUpdateStatementBufferSize = 2048; // Increment this version whenever updating DB tables. static const int32 kCurrentDBVersion = 67; +#if OS_WIN // TODO(sync): remove static void PathNameMatch16(sqlite3_context* context, int argc, sqlite3_value** argv) { @@ -67,6 +72,7 @@ static void PathNameMatch16WithEscape(sqlite3_context* context, // Never seen this called, but just in case. LOG(FATAL) << "PathNameMatch16WithEscape() not implemented"; } +#endif static void RegisterPathNameCollate(sqlite3* dbhandle) { #ifdef OS_WIN @@ -245,8 +251,10 @@ static string ComposeCreateTableColumnSpecs(const ColumnSpec* begin, DirectoryBackingStore::DirectoryBackingStore(const PathString& dir_name, const PathString& backing_filepath) - : dir_name_(dir_name), backing_filepath_(backing_filepath), - load_dbhandle_(NULL), save_dbhandle_(NULL) { + : load_dbhandle_(NULL), + save_dbhandle_(NULL), + dir_name_(dir_name), + backing_filepath_(backing_filepath) { } DirectoryBackingStore::~DirectoryBackingStore() { @@ -636,7 +644,7 @@ int DirectoryBackingStore::CreateTables() { GenerateCacheGUID()); // cache_guid // Create the big metas table. string query = "CREATE TABLE metas " + ComposeCreateTableColumnSpecs - (g_metas_columns, g_metas_columns + ARRAYSIZE(g_metas_columns)); + (g_metas_columns, g_metas_columns + arraysize(g_metas_columns)); result = SQLITE_DONE != result ? result : Exec(load_dbhandle_, query.c_str()); // Insert the entry for the root into the metas table. const int64 now = Now(); diff --git a/chrome/browser/sync/syncable/directory_manager.cc b/chrome/browser/sync/syncable/directory_manager.cc index 0c0c899..4ce70ff 100644 --- a/chrome/browser/sync/syncable/directory_manager.cc +++ b/chrome/browser/sync/syncable/directory_manager.cc @@ -37,8 +37,8 @@ const PathString DirectoryManager::GetSyncDataDatabasePath() const { DirectoryManager::DirectoryManager(const PathString& path) : root_path_(AppendSlash(path)), - channel_(new Channel(DirectoryManagerShutdownEvent())), - managed_directory_(NULL) { + managed_directory_(NULL), + channel_(new Channel(DirectoryManagerShutdownEvent())) { CHECK(0 == pthread_mutex_init(&mutex_, NULL)); } diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index ef63f13..87a3037 100644 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -7,12 +7,13 @@ #include "build/build_config.h" #include <sys/stat.h> +#ifdef OS_LINUX +#include <sys/time.h> +#endif #include <sys/types.h> #include <time.h> #ifdef OS_MACOSX #include <CoreFoundation/CoreFoundation.h> -#elif defined(OS_LINUX) -#include <glib.h> #elif defined(OS_WIN) #include <shlwapi.h> // for PathMatchSpec #endif @@ -102,20 +103,14 @@ int ComparePathNames16(void*, int a_bytes, const void* a, int b_bytes, CHECK(0 != result) << "Error comparing strings: " << GetLastError(); return result - 2; // Convert to -1, 0, 1 #elif defined(OS_LINUX) -// misnomer for Linux. These are already utf8 bit strings. - gchar *case_folded_a; - gchar *case_folded_b; - GError *err = NULL; - case_folded_a = g_utf8_casefold(reinterpret_cast<const gchar*>(a), a_bytes); - CHECK(case_folded_a != NULL) << "g_utf8_casefold failed"; - case_folded_b = g_utf8_casefold(reinterpret_cast<const gchar*>(b), b_bytes); - CHECK(case_folded_b != NULL) << "g_utf8_casefold failed"; - gint result = g_utf8_collate(case_folded_a, case_folded_b); - g_free(case_folded_a); - g_free(case_folded_b); - if (result < 0) return -1; - if (result > 0) return 1; - return 0; + int result = base::strncasecmp(reinterpret_cast<const char *>(a), + reinterpret_cast<const char *>(b), + std::min(a_bytes, b_bytes)); + if (result != 0) { + return result; + } else { + return a_bytes > b_bytes ? 1 : b_bytes > a_bytes ? -1 : 0; + } #elif defined(OS_MACOSX) CFStringRef a_str; CFStringRef b_str; @@ -210,9 +205,9 @@ Directory::Kernel::Kernel(const PathString& db_path, last_sync_timestamp_(info.kernel_info.last_sync_timestamp), initial_sync_ended_(info.kernel_info.initial_sync_ended), store_birthday_(info.kernel_info.store_birthday), - next_id(info.kernel_info.next_id), cache_guid_(info.cache_guid), - next_metahandle(info.max_metahandle + 1) { + next_metahandle(info.max_metahandle + 1), + next_id(info.kernel_info.next_id) { info_status_ = Directory::KERNEL_SHARE_INFO_VALID; CHECK(0 == pthread_mutex_init(&mutex, NULL)); CHECK(0 == pthread_key_create(&thread_node_key, &DestroyThreadNodeKey)); @@ -811,9 +806,9 @@ void Directory::VacuumAfterSaveChanges(const SaveChangesSnapshot& snapshot) { size_t num_erased = 0; kernel_->flushed_metahandles_.Push(entry->ref(META_HANDLE)); num_erased = kernel_->ids_index->erase(entry); - DCHECK_EQ(1, num_erased); + DCHECK(1 == num_erased); num_erased = kernel_->metahandles_index->erase(entry); - DCHECK_EQ(1, num_erased); + DCHECK(1 == num_erased); delete entry; } } diff --git a/chrome/browser/sync/syncable/syncable_columns.h b/chrome/browser/sync/syncable/syncable_columns.h index 10f7578..cd6f281 100644 --- a/chrome/browser/sync/syncable/syncable_columns.h +++ b/chrome/browser/sync/syncable/syncable_columns.h @@ -65,8 +65,8 @@ static const ColumnSpec g_metas_columns[] = { }; // At least enforce that there are equal number of column names and fields. -COMPILE_ASSERT(ARRAYSIZE(g_metas_columns) >= FIELD_COUNT, missing_column_name); -COMPILE_ASSERT(ARRAYSIZE(g_metas_columns) <= FIELD_COUNT, extra_column_names); +COMPILE_ASSERT(arraysize(g_metas_columns) >= FIELD_COUNT, missing_column_name); +COMPILE_ASSERT(arraysize(g_metas_columns) <= FIELD_COUNT, extra_column_names); static inline const char* ColumnName(int field) { DCHECK(field < BEGIN_TEMPS); diff --git a/chrome/browser/sync/util/character_set_converters.h b/chrome/browser/sync/util/character_set_converters.h index 3e614c3..1db32c7 100644 --- a/chrome/browser/sync/util/character_set_converters.h +++ b/chrome/browser/sync/util/character_set_converters.h @@ -24,10 +24,6 @@ // CHECK(browser_sync::Append(utf8, &bob)); // PathString fred = bob; -#ifdef OS_LINUX -#include <glib.h> -#endif - #include <string> #include "base/basictypes.h" diff --git a/chrome/browser/sync/util/character_set_converters_linux.cc b/chrome/browser/sync/util/character_set_converters_linux.cc index 96ad1b6..3cbcca8 100644 --- a/chrome/browser/sync/util/character_set_converters_linux.cc +++ b/chrome/browser/sync/util/character_set_converters_linux.cc @@ -29,7 +29,7 @@ void TrimPathStringToValidCharacter(PathString* string) { return; if (0 == (string->at(string->length() - 1) & 0x080)) return; - int partial_enc_bytes = 0; + size_t partial_enc_bytes = 0; for (partial_enc_bytes = 0 ; true ; ++partial_enc_bytes) { if (4 == partial_enc_bytes || partial_enc_bytes == string->length()) { // original string was broken, garbage in, garbage out. diff --git a/chrome/browser/sync/util/compat_file_posix.cc b/chrome/browser/sync/util/compat_file_posix.cc index aecc2bb..62ba56f 100644 --- a/chrome/browser/sync/util/compat_file_posix.cc +++ b/chrome/browser/sync/util/compat_file_posix.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#if ((!defined(OS_LINUX)) && (!defined(OS_MACOSX))) +#if !defined(POSIX) #error Compile this file on Mac OS X or Linux only. #endif #include "chrome/browser/sync/util/compat_file.h" const char* const kPathSeparator = "/"; - diff --git a/chrome/browser/sync/util/compat_pthread.h b/chrome/browser/sync/util/compat_pthread.h index 3ea6a83..1bcc1f0 100644 --- a/chrome/browser/sync/util/compat_pthread.h +++ b/chrome/browser/sync/util/compat_pthread.h @@ -19,21 +19,4 @@ inline ThreadId GetCurrentThreadId() { } #endif // OS_WIN -#if (!defined(OS_WIN) && !defined(OS_MACOSX)) -// TODO(timsteele): What the heck is this? -inline int sem_post_multiple(sem_t* sem, int number) { - int i; - int r = 0; - for (i = 0; i < number; i++) { - r = sem_post(sem); - if (r != 0) { - LOG_IF(ERROR, i > 0) << "sem_post() failed on iteration #" << i << - " of " << number; - return r; - } - } - return 0; -} -#endif // (!defined(OS_WIN) && !defined(OS_MACOSX)) - #endif // CHROME_BROWSER_SYNC_UTIL_COMPAT_PTHREAD_H_ diff --git a/chrome/browser/sync/util/event_sys-inl.h b/chrome/browser/sync/util/event_sys-inl.h index 3b5c944..9e45506 100644 --- a/chrome/browser/sync/util/event_sys-inl.h +++ b/chrome/browser/sync/util/event_sys-inl.h @@ -105,8 +105,9 @@ class EventChannel { public: // The shutdown event gets send in the EventChannel's destructor. explicit EventChannel(const EventType& shutdown_event) - : callback_waiters_(NULL), shutdown_event_(shutdown_event), - current_listener_callback_(NULL) { + : current_listener_callback_(NULL), + callback_waiters_(NULL), + shutdown_event_(shutdown_event) { } ~EventChannel() { diff --git a/chrome/browser/sync/util/path_helpers.h b/chrome/browser/sync/util/path_helpers.h index e6976a8..b370fbd 100644 --- a/chrome/browser/sync/util/path_helpers.h +++ b/chrome/browser/sync/util/path_helpers.h @@ -72,7 +72,6 @@ PathString LastPathSegment(const PathString& path); std::string LastPathSegment(const std::string& path); PathString AppendSlash(const PathString& path); PathString GetFullPath(const PathString& path); -PathString LowercasePath(const PathString& path); PathString ExpandTilde(const PathString& path); inline bool HasSuffixPathString(const PathString& str, diff --git a/chrome/browser/sync/util/path_helpers_linux.cc b/chrome/browser/sync/util/path_helpers_linux.cc index 2448f09..851e868 100644 --- a/chrome/browser/sync/util/path_helpers_linux.cc +++ b/chrome/browser/sync/util/path_helpers_linux.cc @@ -4,7 +4,6 @@ #include <sys/types.h> -#include <glib.h> #include <string.h> #include "base/logging.h" @@ -42,10 +41,3 @@ PathString AppendSlash(const PathString& path) { } return path; } - -PathString LowercasePath(const PathString& path) { - gchar* ret = g_utf8_strdown(path.c_str(), -1); - PathString retstr(ret); - g_free(ret); - return retstr; -} diff --git a/chrome/browser/sync/util/path_helpers_posix.cc b/chrome/browser/sync/util/path_helpers_posix.cc index e8f7fd3..5c68177 100644 --- a/chrome/browser/sync/util/path_helpers_posix.cc +++ b/chrome/browser/sync/util/path_helpers_posix.cc @@ -5,6 +5,7 @@ #include <pwd.h> #include <string.h> +#include "chrome/browser/sync/notifier/base/string.h" #include "chrome/browser/sync/util/path_helpers.h" #if ((!defined(OS_LINUX)) && (!defined(OS_MACOSX))) @@ -25,15 +26,15 @@ PathString ExpandTilde(const PathString& path) { namespace { // TODO(sync): We really should use char[]. -string cache_dir_; + std::string cache_dir_; } -void set_cache_dir(string cache_dir) { +void set_cache_dir(std::string cache_dir) { CHECK(cache_dir_.empty()); cache_dir_ = cache_dir; } -string get_cache_dir() { +std::string get_cache_dir() { CHECK(!cache_dir_.empty()); return cache_dir_; } @@ -41,7 +42,7 @@ string get_cache_dir() { // On Posix, PathStrings are UTF-8, not UTF-16 as they are on Windows. Thus, // this function is different from the Windows version. PathString TruncatePathString(const PathString& original, int length) { - if (original.size() <= length) + if (original.size() <= static_cast<size_t>(length)) return original; if (length <= 0) return original; @@ -89,8 +90,7 @@ PathString TruncatePathString(const PathString& original, int length) { PathString MakePathComponentOSLegal(const PathString& component) { if (PathString::npos == component.find("/")) return PSTR(""); - PathString new_name; - new_name.reserve(component.size()); - StringReplace(component, "/", ":", true, &new_name); + PathString new_name(component); + notifier::StringReplace(&new_name, "/", ":", true); return new_name; } diff --git a/chrome/browser/sync/util/pthread_helpers.cc b/chrome/browser/sync/util/pthread_helpers.cc index 809f5f6..ff96409 100644 --- a/chrome/browser/sync/util/pthread_helpers.cc +++ b/chrome/browser/sync/util/pthread_helpers.cc @@ -133,7 +133,7 @@ struct timespec GetPThreadAbsoluteTime(uint32 ms) { #endif // OS_WIN } -void NameCurrentThreadForDebugging(char* name) { +void NameCurrentThreadForDebugging(const char* name) { #if defined(OS_WIN) // This implementation is taken from Chromium's platform_thread framework. // The information on how to set the thread name comes from a MSDN article: diff --git a/chrome/browser/sync/util/pthread_helpers.h b/chrome/browser/sync/util/pthread_helpers.h index c231f67..3886b7f 100644 --- a/chrome/browser/sync/util/pthread_helpers.h +++ b/chrome/browser/sync/util/pthread_helpers.h @@ -255,6 +255,6 @@ struct timespec GetPThreadAbsoluteTime(uint32 ms_from_now); // Assign a descriptive label to the current thread. This is useful to see // in a GUI debugger, but may not be implementable on all platforms. -void NameCurrentThreadForDebugging(char* name); +void NameCurrentThreadForDebugging(const char* name); #endif // CHROME_BROWSER_SYNC_UTIL_PTHREAD_HELPERS_H_ diff --git a/chrome/browser/sync/util/query_helpers.h b/chrome/browser/sync/util/query_helpers.h index 0aee3ad..54cda1f 100644 --- a/chrome/browser/sync/util/query_helpers.h +++ b/chrome/browser/sync/util/query_helpers.h @@ -17,12 +17,6 @@ #include "chrome/browser/sync/util/sync_types.h" #include "third_party/sqlite/preprocessed/sqlite3.h" -// Sometimes threads contend on the DB lock itself, especially when one thread -// is calling SaveChanges. In the worst case scenario, the user can put his -// laptop to sleep during db contention, and wake up the laptop days later, so -// infinity seems like the best choice here. -const int kDirectoryBackingStoreBusyTimeoutMs = std::numeric_limits<int>::max(); - enum SqliteNullType { SQLITE_NULL_VALUE }; diff --git a/chrome/browser/sync/util/sync_types.h b/chrome/browser/sync/util/sync_types.h index 02dad41..26469cc 100644 --- a/chrome/browser/sync/util/sync_types.h +++ b/chrome/browser/sync/util/sync_types.h @@ -35,7 +35,7 @@ inline size_t PathLen(const wchar_t* s) { #else // Mac and Linux #define PATHSTRING_IS_STD_STRING 1 #define PSTR_CHAR char -typedef string PathString; +typedef std::string PathString; #define PSTR(s) s inline size_t PathLen(const char* s) { return strlen(s); @@ -71,6 +71,6 @@ inline PathString IntToPathString(int digit) { return PathString(tmp.begin(), tmp.end()); } -const int kSyncProtocolMaxNameLengthBytes = 255; +const size_t kSyncProtocolMaxNameLengthBytes = 255; #endif // CHROME_BROWSER_SYNC_UTIL_SYNC_TYPES_H_ diff --git a/chrome/browser/sync/util/user_settings.cc b/chrome/browser/sync/util/user_settings.cc index d9ff1bd..6dbde96 100644 --- a/chrome/browser/sync/util/user_settings.cc +++ b/chrome/browser/sync/util/user_settings.cc @@ -88,8 +88,8 @@ void UserSettings::MigrateOldVersionsAsNeeded(sqlite3* const handle, GetColumn(share_query.get(), 0, &share_name); GetColumn(share_query.get(), 1, &file_name); - if (!file_util::Move(file_name, - DirectoryManager::GetSyncDataDatabaseFilename())) { + if (!file_util::Move(FilePath(file_name), + FilePath(DirectoryManager::GetSyncDataDatabaseFilename()))) { LOG(WARNING) << "Unable to upgrade UserSettings from v10"; return; } diff --git a/chrome/browser/sync/util/user_settings_posix.cc b/chrome/browser/sync/util/user_settings_posix.cc index 736d2d1..f8fd3f0 100644 --- a/chrome/browser/sync/util/user_settings_posix.cc +++ b/chrome/browser/sync/util/user_settings_posix.cc @@ -12,14 +12,16 @@ void UserSettings::ClearAllServiceTokens() { service_tokens_.clear(); } -void UserSettings::SetAuthTokenForService(const string& email, - const string& service_name, const string& long_lived_service_token) { +void UserSettings::SetAuthTokenForService( + const std::string& email, + const std::string& service_name, + const std::string& long_lived_service_token) { service_tokens_[service_name] = long_lived_service_token; } -bool UserSettings::GetLastUserAndServiceToken(const string& service_name, - string* username, - string* service_token) { +bool UserSettings::GetLastUserAndServiceToken(const std::string& service_name, + std::string* username, + std::string* service_token) { ServiceTokenMap::const_iterator iter = service_tokens_.find(service_name); if (iter != service_tokens_.end()) { |