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

Side by Side Diff: chrome/browser/sync_file_system/drive_metadata_store.cc

Issue 15657002: Mirror syncfs log to console and WebUI, with LogSeverity support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_file_system/drive_metadata_store.h" 5 #include "chrome/browser/sync_file_system/drive_metadata_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" 20 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
21 #include "chrome/browser/sync_file_system/logger.h"
21 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" 22 #include "chrome/browser/sync_file_system/sync_file_system.pb.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "third_party/leveldatabase/src/include/leveldb/db.h" 24 #include "third_party/leveldatabase/src/include/leveldb/db.h"
24 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 25 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
25 #include "webkit/fileapi/file_system_url.h" 26 #include "webkit/fileapi/file_system_url.h"
26 #include "webkit/fileapi/file_system_util.h" 27 #include "webkit/fileapi/file_system_util.h"
27 #include "webkit/fileapi/syncable/syncable_file_system_util.h" 28 #include "webkit/fileapi/syncable/syncable_file_system_util.h"
28 29
29 using fileapi::FileSystemURL; 30 using fileapi::FileSystemURL;
30 31
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 contents->disabled_origins.clear(); 192 contents->disabled_origins.clear();
192 193
193 bool created = false; 194 bool created = false;
194 SyncStatusCode status = db->Initialize(&created); 195 SyncStatusCode status = db->Initialize(&created);
195 if (status != SYNC_STATUS_OK) 196 if (status != SYNC_STATUS_OK)
196 return status; 197 return status;
197 198
198 if (!created) { 199 if (!created) {
199 status = db->MigrateDatabaseIfNeeded(); 200 status = db->MigrateDatabaseIfNeeded();
200 if (status != SYNC_STATUS_OK) { 201 if (status != SYNC_STATUS_OK) {
201 LOG(WARNING) << "Failed to migrate DriveMetadataStore to latest version."; 202 util::Log(logging::LOG_WARNING,
203 "Failed to migrate DriveMetadataStore to latest version.");
202 return status; 204 return status;
203 } 205 }
204 } 206 }
205 207
206 return db->ReadContents(contents); 208 return db->ReadContents(contents);
207 } 209 }
208 210
209 // Returns a key string for the given origin. 211 // Returns a key string for the given origin.
210 // For example, when |origin| is "http://www.example.com" and |sync_type| is 212 // For example, when |origin| is "http://www.example.com" and |sync_type| is
211 // BATCH_SYNC_ORIGIN, returns "BSYNC_ORIGIN: http://www.example.com". 213 // BATCH_SYNC_ORIGIN, returns "BSYNC_ORIGIN: http://www.example.com".
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 UpdateDBStatus(status); 663 UpdateDBStatus(status);
662 callback.Run(status); 664 callback.Run(status);
663 } 665 }
664 666
665 void DriveMetadataStore::UpdateDBStatus(SyncStatusCode status) { 667 void DriveMetadataStore::UpdateDBStatus(SyncStatusCode status) {
666 DCHECK(CalledOnValidThread()); 668 DCHECK(CalledOnValidThread());
667 if (db_status_ != SYNC_STATUS_OK && 669 if (db_status_ != SYNC_STATUS_OK &&
668 db_status_ != SYNC_DATABASE_ERROR_NOT_FOUND) { 670 db_status_ != SYNC_DATABASE_ERROR_NOT_FOUND) {
669 // TODO(tzik): Handle database corruption. http://crbug.com/153709 671 // TODO(tzik): Handle database corruption. http://crbug.com/153709
670 db_status_ = status; 672 db_status_ = status;
671 LOG(WARNING) << "DriveMetadataStore turned to wrong state: " << status; 673 util::Log(logging::LOG_WARNING,
674 std::string("DriveMetadataStore turned to wrong state: ").append(
675 SyncStatusCodeToString(status)));
672 return; 676 return;
673 } 677 }
674 db_status_ = SYNC_STATUS_OK; 678 db_status_ = SYNC_STATUS_OK;
675 } 679 }
676 680
677 void DriveMetadataStore::UpdateDBStatusAndInvokeCallback( 681 void DriveMetadataStore::UpdateDBStatusAndInvokeCallback(
678 const SyncStatusCallback& callback, 682 const SyncStatusCallback& callback,
679 SyncStatusCode status) { 683 SyncStatusCode status) {
680 UpdateDBStatus(status); 684 UpdateDBStatus(status);
681 callback.Run(status); 685 callback.Run(status);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 DCHECK(origin.is_valid()); 1183 DCHECK(origin.is_valid());
1180 bool result = disabled_origins->insert( 1184 bool result = disabled_origins->insert(
1181 std::make_pair(origin, itr->value().ToString())).second; 1185 std::make_pair(origin, itr->value().ToString())).second;
1182 DCHECK(result); 1186 DCHECK(result);
1183 } 1187 }
1184 1188
1185 return SYNC_STATUS_OK; 1189 return SYNC_STATUS_OK;
1186 } 1190 }
1187 1191
1188 } // namespace sync_file_system 1192 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698