| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" |
| 6 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 7 #include "base/file_util.h" | |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 9 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
| 10 #include "chrome/browser/sync/glue/change_processor.h" | 11 #include "chrome/browser/sync/glue/change_processor.h" |
| 11 #include "chrome/browser/sync/glue/sync_backend_host.h" | 12 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 12 #include "chrome/browser/sync/glue/http_bridge.h" | 13 #include "chrome/browser/sync/glue/http_bridge.h" |
| 13 #include "chrome/browser/sync/glue/bookmark_model_worker.h" | 14 #include "chrome/browser/sync/glue/bookmark_model_worker.h" |
| 14 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
| 15 | 16 |
| 16 static const int kSaveChangesIntervalSeconds = 10; | 17 static const int kSaveChangesIntervalSeconds = 10; |
| 17 static const char kGaiaServiceId[] = "chromiumsync"; | 18 static const char kGaiaServiceId[] = "chromiumsync"; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 sync_api::HttpPostProviderFactory* http_provider_factory, | 168 sync_api::HttpPostProviderFactory* http_provider_factory, |
| 168 sync_api::HttpPostProviderFactory* auth_http_provider_factory) { | 169 sync_api::HttpPostProviderFactory* auth_http_provider_factory) { |
| 169 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); | 170 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); |
| 170 | 171 |
| 171 // Make sure that the directory exists before initializing the backend. | 172 // Make sure that the directory exists before initializing the backend. |
| 172 // If it already exists, this will do no harm. | 173 // If it already exists, this will do no harm. |
| 173 bool success = file_util::CreateDirectory(host_->sync_data_folder_path()); | 174 bool success = file_util::CreateDirectory(host_->sync_data_folder_path()); |
| 174 DCHECK(success); | 175 DCHECK(success); |
| 175 | 176 |
| 176 syncapi_->SetObserver(this); | 177 syncapi_->SetObserver(this); |
| 177 string16 path_str; | 178 const FilePath& path_str = host_->sync_data_folder_path(); |
| 178 #if defined (OS_WIN) | 179 success = syncapi_->Init(path_str, |
| 179 path_str = host_->sync_data_folder_path().value(); | |
| 180 #elif defined(OS_LINUX) || defined(OS_MACOSX) | |
| 181 path_str = UTF8ToUTF16(host_->sync_data_folder_path().value()); | |
| 182 #endif | |
| 183 success = syncapi_->Init(path_str.c_str(), | |
| 184 (service_url.host() + service_url.path()).c_str(), | 180 (service_url.host() + service_url.path()).c_str(), |
| 185 service_url.EffectiveIntPort(), | 181 service_url.EffectiveIntPort(), |
| 186 kGaiaServiceId, | 182 kGaiaServiceId, |
| 187 kGaiaSourceForChrome, | 183 kGaiaSourceForChrome, |
| 188 service_url.SchemeIsSecure(), | 184 service_url.SchemeIsSecure(), |
| 189 http_provider_factory, | 185 http_provider_factory, |
| 190 auth_http_provider_factory, | 186 auth_http_provider_factory, |
| 191 bookmark_model_worker, | 187 bookmark_model_worker, |
| 192 attempt_last_user_authentication, | 188 attempt_last_user_authentication, |
| 193 MakeUserAgentForSyncapi().c_str()); | 189 MakeUserAgentForSyncapi().c_str()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 save_changes_timer_.Start( | 300 save_changes_timer_.Start( |
| 305 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), | 301 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), |
| 306 this, &Core::SaveChanges); | 302 this, &Core::SaveChanges); |
| 307 } | 303 } |
| 308 | 304 |
| 309 void SyncBackendHost::Core::SaveChanges() { | 305 void SyncBackendHost::Core::SaveChanges() { |
| 310 syncapi_->SaveChanges(); | 306 syncapi_->SaveChanges(); |
| 311 } | 307 } |
| 312 | 308 |
| 313 } // namespace browser_sync | 309 } // namespace browser_sync |
| OLD | NEW |