From bac3d04d6bdabbb68e1b6701dc93853070ac4f5c Mon Sep 17 00:00:00 2001 From: "akalin@chromium.org" Date: Tue, 13 Oct 2009 22:25:24 +0000 Subject: Patched in 265058 (which was uploaded under akalin@gmail.com). Original description: Numerous fixes to get parts of Chrome Sync to compile on OS X. Fixes include: - Added missing definitions for some static const class variables. - Added some missing dependencies. - Marked some Windows-only dependencies as such. - Added stub files for some platform-specific classes. BUG=none TEST=Put through trybots. Review URL: http://codereview.chromium.org/266065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28900 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/sync/engine/syncer_thread.cc | 4 ++ chrome/browser/sync/engine/syncer_thread.h | 6 +-- chrome/browser/sync/glue/bookmark_model_worker.cc | 1 + chrome/browser/sync/glue/bookmark_model_worker.h | 3 +- chrome/browser/sync/glue/change_processor.h | 4 +- chrome/browser/sync/glue/model_associator.h | 3 +- chrome/browser/sync/glue/sync_backend_host.cc | 6 +-- .../base/mac/network_status_detector_task_mac.cc | 16 ++++++ chrome/browser/sync/notifier/base/mac/time_mac.cc | 8 +++ chrome/browser/sync/profile_sync_service.h | 6 +-- .../sync/util/character_set_converters_linux.cc | 60 --------------------- .../sync/util/character_set_converters_posix.cc | 61 ++++++++++++++++++++++ chrome/browser/sync/util/path_helpers_linux.cc | 27 ---------- chrome/browser/sync/util/path_helpers_mac.cc | 17 ++++++ chrome/browser/sync/util/path_helpers_posix.cc | 27 ++++++++++ 15 files changed, 149 insertions(+), 100 deletions(-) create mode 100644 chrome/browser/sync/notifier/base/mac/network_status_detector_task_mac.cc create mode 100644 chrome/browser/sync/notifier/base/mac/time_mac.cc delete mode 100644 chrome/browser/sync/util/character_set_converters_linux.cc create mode 100644 chrome/browser/sync/util/character_set_converters_posix.cc create mode 100644 chrome/browser/sync/util/path_helpers_mac.cc (limited to 'chrome/browser') diff --git a/chrome/browser/sync/engine/syncer_thread.cc b/chrome/browser/sync/engine/syncer_thread.cc index 478e0f7..e509a83 100644 --- a/chrome/browser/sync/engine/syncer_thread.cc +++ b/chrome/browser/sync/engine/syncer_thread.cc @@ -109,6 +109,10 @@ int UserIdleTime() { namespace browser_sync { +const int SyncerThread::kDefaultShortPollIntervalSeconds = 60; +const int SyncerThread::kDefaultLongPollIntervalSeconds = 3600; +const int SyncerThread::kDefaultMaxPollIntervalMs = 30 * 60 * 1000; + SyncerThread* SyncerThreadFactory::Create( ClientCommandChannel* command_channel, syncable::DirectoryManager* mgr, diff --git a/chrome/browser/sync/engine/syncer_thread.h b/chrome/browser/sync/engine/syncer_thread.h index e699b49..d6fc63a 100644 --- a/chrome/browser/sync/engine/syncer_thread.h +++ b/chrome/browser/sync/engine/syncer_thread.h @@ -82,12 +82,12 @@ public: }; // Server can overwrite these values via client commands. // Standard short poll. This is used when XMPP is off. - static const int kDefaultShortPollIntervalSeconds = 60; + static const int kDefaultShortPollIntervalSeconds; // Long poll is used when XMPP is on. - static const int kDefaultLongPollIntervalSeconds = 3600; + static const int kDefaultLongPollIntervalSeconds; // 30 minutes by default. If exponential backoff kicks in, this is the // longest possible poll interval. - static const int kDefaultMaxPollIntervalMs = 30 * 60 * 1000; + static const int kDefaultMaxPollIntervalMs; virtual ~SyncerThread(); diff --git a/chrome/browser/sync/glue/bookmark_model_worker.cc b/chrome/browser/sync/glue/bookmark_model_worker.cc index b2a4589..fa30466 100644 --- a/chrome/browser/sync/glue/bookmark_model_worker.cc +++ b/chrome/browser/sync/glue/bookmark_model_worker.cc @@ -112,3 +112,4 @@ void BookmarkModelWorker::CallDoWorkAndSignalTask::Run() { } // namespace browser_sync #endif // CHROME_PERSONALIZATION + diff --git a/chrome/browser/sync/glue/bookmark_model_worker.h b/chrome/browser/sync/glue/bookmark_model_worker.h index 9cd67c6..7ac61e8 100644 --- a/chrome/browser/sync/glue/bookmark_model_worker.h +++ b/chrome/browser/sync/glue/bookmark_model_worker.h @@ -131,4 +131,5 @@ class BookmarkModelWorker #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_WORKER_H_ -#endif // CHROME_PERSONALIZATION \ No newline at end of file +#endif // CHROME_PERSONALIZATION + diff --git a/chrome/browser/sync/glue/change_processor.h b/chrome/browser/sync/glue/change_processor.h index e9b15d4..c5c43f7 100644 --- a/chrome/browser/sync/glue/change_processor.h +++ b/chrome/browser/sync/glue/change_processor.h @@ -26,8 +26,8 @@ class ChangeProcessor : public BookmarkModelObserver, public ChangeProcessingInterface { public: ChangeProcessor(UnrecoverableErrorHandler* error_handler) - : error_handler_(error_handler), model_associator_(NULL), - share_handle_(NULL), running_(false), bookmark_model_(NULL) {} + : running_(false), error_handler_(error_handler), + bookmark_model_(NULL), share_handle_(NULL), model_associator_(NULL) {} virtual ~ChangeProcessor() { Stop(); } // Call when the processor should accept changes from either provided model diff --git a/chrome/browser/sync/glue/model_associator.h b/chrome/browser/sync/glue/model_associator.h index a3b6e766e..6c3776e 100644 --- a/chrome/browser/sync/glue/model_associator.h +++ b/chrome/browser/sync/glue/model_associator.h @@ -140,4 +140,5 @@ class ModelAssociator } // namespace browser_sync #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCATOR_H_ -#endif // CHROME_PERSONALIZATION \ No newline at end of file +#endif // CHROME_PERSONALIZATION + diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index 93c7a9d..a875229 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -137,8 +137,8 @@ void SyncBackendHost::Core::SetBaseRequestContext( SyncBackendHost::Core::Core(SyncBackendHost* backend) : host_(backend), - syncapi_(new sync_api::SyncManager()), - base_request_context_(NULL) { + base_request_context_(NULL), + syncapi_(new sync_api::SyncManager()) { } SyncBackendHost::Core::~Core() { @@ -192,7 +192,7 @@ void SyncBackendHost::Core::DoInitialize( #if defined (OS_WIN) path_str = host_->sync_data_folder_path().value(); #elif (defined(OS_LINUX) || defined(OS_MACOSX)) - path_str = UTF8ToUTF16(sync_data_folder_path().value()); + path_str = UTF8ToUTF16(host_->sync_data_folder_path().value()); #endif success = syncapi_->Init(path_str.c_str(), (service_url.host() + service_url.path()).c_str(), diff --git a/chrome/browser/sync/notifier/base/mac/network_status_detector_task_mac.cc b/chrome/browser/sync/notifier/base/mac/network_status_detector_task_mac.cc new file mode 100644 index 0000000..527df79 --- /dev/null +++ b/chrome/browser/sync/notifier/base/mac/network_status_detector_task_mac.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/notifier/base/network_status_detector_task.h" + +namespace notifier { + +NetworkStatusDetectorTask* NetworkStatusDetectorTask::Create( + talk_base::Task* parent) { + // TODO(sync): No implementation for OS X. + return NULL; +} + +} // namespace notifier + diff --git a/chrome/browser/sync/notifier/base/mac/time_mac.cc b/chrome/browser/sync/notifier/base/mac/time_mac.cc new file mode 100644 index 0000000..93fca5d --- /dev/null +++ b/chrome/browser/sync/notifier/base/mac/time_mac.cc @@ -0,0 +1,8 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Time functions + +#include "chrome/browser/sync/notifier/base/posix/time_posix.cc" + diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index 042c963..011f55f 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -108,9 +108,9 @@ class ProfileSyncService : public NotificationObserver, void SetSyncSetupCompleted(); // NotificationObserver implementation. - virtual void ProfileSyncService::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); // SyncFrontend implementation. virtual void OnBackendInitialized(); diff --git a/chrome/browser/sync/util/character_set_converters_linux.cc b/chrome/browser/sync/util/character_set_converters_linux.cc deleted file mode 100644 index 3cbcca8..0000000 --- a/chrome/browser/sync/util/character_set_converters_linux.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/character_set_converters.h" - -#include - -using std::string; - -namespace browser_sync { - -// Converts input_string to UTF8 and appends the result into output_string. -void AppendPathStringToUTF8(const PathChar *wide, int size, - string* output_string) { - output_string->append(wide, size); -} - -bool AppendUTF8ToPathString(const char* utf8, size_t size, - PathString* output_string) { - output_string->append(utf8, size); - return true; -} - -void TrimPathStringToValidCharacter(PathString* string) { - // Constants from http://en.wikipedia.org/wiki/UTF-8 - CHECK(string); - if (string->empty()) - return; - if (0 == (string->at(string->length() - 1) & 0x080)) - return; - 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. - return; - } - PathChar c = string->at(string->length() - 1 - partial_enc_bytes); - if ((c & 0x0c0) == 0x080) // utf continuation char; - continue; - if ((c & 0x0e0) == 0x0e0) // 2-byte encoded char. - if (1 == partial_enc_bytes) - return; - else - break; - if ((c & 0x0f0) == 0xc0) // 3-byte encoded char. - if (2 == partial_enc_bytes) - return; - else - break; - if ((c & 0x0f8) == 0x0f0) // 4-byte encoded char. - if (3 == partial_enc_bytes) - return; - else - break; - } - string->resize(string->length() - 1 - partial_enc_bytes); -} - -} // namespace browser_sync diff --git a/chrome/browser/sync/util/character_set_converters_posix.cc b/chrome/browser/sync/util/character_set_converters_posix.cc new file mode 100644 index 0000000..d038f1f --- /dev/null +++ b/chrome/browser/sync/util/character_set_converters_posix.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/util/character_set_converters.h" + +#include + +using std::string; + +namespace browser_sync { + +// Converts input_string to UTF8 and appends the result into output_string. +void AppendPathStringToUTF8(const PathChar *wide, int size, + string* output_string) { + output_string->append(wide, size); +} + +bool AppendUTF8ToPathString(const char* utf8, size_t size, + PathString* output_string) { + output_string->append(utf8, size); + return true; +} + +void TrimPathStringToValidCharacter(PathString* string) { + // Constants from http://en.wikipedia.org/wiki/UTF-8 + CHECK(string); + if (string->empty()) + return; + if (0 == (string->at(string->length() - 1) & 0x080)) + return; + 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. + return; + } + PathChar c = string->at(string->length() - 1 - partial_enc_bytes); + if ((c & 0x0c0) == 0x080) // utf continuation char; + continue; + if ((c & 0x0e0) == 0x0e0) // 2-byte encoded char. + if (1 == partial_enc_bytes) + return; + else + break; + if ((c & 0x0f0) == 0xc0) // 3-byte encoded char. + if (2 == partial_enc_bytes) + return; + else + break; + if ((c & 0x0f8) == 0x0f0) // 4-byte encoded char. + if (3 == partial_enc_bytes) + return; + else + break; + } + string->resize(string->length() - 1 - partial_enc_bytes); +} + +} // namespace browser_sync + diff --git a/chrome/browser/sync/util/path_helpers_linux.cc b/chrome/browser/sync/util/path_helpers_linux.cc index 851e868..157fa48 100644 --- a/chrome/browser/sync/util/path_helpers_linux.cc +++ b/chrome/browser/sync/util/path_helpers_linux.cc @@ -2,42 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include - -#include - -#include "base/logging.h" #include "base/port.h" -#include "chrome/browser/sync/util/character_set_converters.h" #include "chrome/browser/sync/util/path_helpers.h" #ifndef OS_LINUX #error Compile this file on Linux only. #endif -string LastPathSegment(const string& path) { - string str(path); - string::size_type final_slash = str.find_last_of('/'); - if (string::npos != final_slash && final_slash == str.length() - 1 - && str.length() > 1) { - str.erase(final_slash); - final_slash = str.find_last_of('/'); - } - if (string::npos == final_slash) - return str; - str.erase(0, final_slash + 1); - return str; -} - PathString GetFullPath(const PathString& path) { // TODO(sync): Not sure what the base of the relative path should be on // linux. return path; } - -PathString AppendSlash(const PathString& path) { - if ((!path.empty()) && (*path.rbegin() != '/')) { - return path + '/'; - } - return path; -} diff --git a/chrome/browser/sync/util/path_helpers_mac.cc b/chrome/browser/sync/util/path_helpers_mac.cc new file mode 100644 index 0000000..3b1c84a --- /dev/null +++ b/chrome/browser/sync/util/path_helpers_mac.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/port.h" +#include "chrome/browser/sync/util/path_helpers.h" + +#ifndef OS_MACOSX +#error Compile this file on Mac only. +#endif + +PathString GetFullPath(const PathString& path) { + // TODO(sync): Not sure what the base of the relative path should be on + // OS X. + return path; +} + diff --git a/chrome/browser/sync/util/path_helpers_posix.cc b/chrome/browser/sync/util/path_helpers_posix.cc index 9da1adb..f613f44 100644 --- a/chrome/browser/sync/util/path_helpers_posix.cc +++ b/chrome/browser/sync/util/path_helpers_posix.cc @@ -2,10 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include #include #include +#include "base/logging.h" +#include "base/port.h" +#include "chrome/browser/sync/util/character_set_converters.h" #include "chrome/browser/sync/util/path_helpers.h" #if ((!defined(OS_LINUX)) && (!defined(OS_MACOSX))) @@ -94,3 +99,25 @@ PathString MakePathComponentOSLegal(const PathString& component) { std::replace(new_name.begin(), new_name.end(), '/', ':'); return new_name; } + +string LastPathSegment(const string& path) { + string str(path); + string::size_type final_slash = str.find_last_of('/'); + if (string::npos != final_slash && final_slash == str.length() - 1 + && str.length() > 1) { + str.erase(final_slash); + final_slash = str.find_last_of('/'); + } + if (string::npos == final_slash) + return str; + str.erase(0, final_slash + 1); + return str; +} + +PathString AppendSlash(const PathString& path) { + if ((!path.empty()) && (*path.rbegin() != '/')) { + return path + '/'; + } + return path; +} + -- cgit v1.1