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

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: expect -> assert fix 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 FROM_HERE,
204 "Failed to migrate DriveMetadataStore to latest version.");
202 return status; 205 return status;
203 } 206 }
204 } 207 }
205 208
206 return db->ReadContents(contents); 209 return db->ReadContents(contents);
207 } 210 }
208 211
209 // Returns a key string for the given origin. 212 // Returns a key string for the given origin.
210 // For example, when |origin| is "http://www.example.com" and |sync_type| is 213 // For example, when |origin| is "http://www.example.com" and |sync_type| is
211 // BATCH_SYNC_ORIGIN, returns "BSYNC_ORIGIN: http://www.example.com". 214 // BATCH_SYNC_ORIGIN, returns "BSYNC_ORIGIN: http://www.example.com".
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 673
671 batch_sync_origins_.erase(found); 674 batch_sync_origins_.erase(found);
672 } 675 }
673 676
674 void DriveMetadataStore::UpdateDBStatus(SyncStatusCode status) { 677 void DriveMetadataStore::UpdateDBStatus(SyncStatusCode status) {
675 DCHECK(CalledOnValidThread()); 678 DCHECK(CalledOnValidThread());
676 if (db_status_ != SYNC_STATUS_OK && 679 if (db_status_ != SYNC_STATUS_OK &&
677 db_status_ != SYNC_DATABASE_ERROR_NOT_FOUND) { 680 db_status_ != SYNC_DATABASE_ERROR_NOT_FOUND) {
678 // TODO(tzik): Handle database corruption. http://crbug.com/153709 681 // TODO(tzik): Handle database corruption. http://crbug.com/153709
679 db_status_ = status; 682 db_status_ = status;
680 LOG(WARNING) << "DriveMetadataStore turned to wrong state: " << status; 683 util::Log(logging::LOG_WARNING,
684 FROM_HERE,
685 "DriveMetadataStore turned to wrong state: %s",
686 SyncStatusCodeToString(status).c_str());
681 return; 687 return;
682 } 688 }
683 db_status_ = SYNC_STATUS_OK; 689 db_status_ = SYNC_STATUS_OK;
684 } 690 }
685 691
686 void DriveMetadataStore::UpdateDBStatusAndInvokeCallback( 692 void DriveMetadataStore::UpdateDBStatusAndInvokeCallback(
687 const SyncStatusCallback& callback, 693 const SyncStatusCallback& callback,
688 SyncStatusCode status) { 694 SyncStatusCode status) {
689 UpdateDBStatus(status); 695 UpdateDBStatus(status);
690 callback.Run(status); 696 callback.Run(status);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 DCHECK(origin.is_valid()); 1194 DCHECK(origin.is_valid());
1189 bool result = disabled_origins->insert( 1195 bool result = disabled_origins->insert(
1190 std::make_pair(origin, itr->value().ToString())).second; 1196 std::make_pair(origin, itr->value().ToString())).second;
1191 DCHECK(result); 1197 DCHECK(result);
1192 } 1198 }
1193 1199
1194 return SYNC_STATUS_OK; 1200 return SYNC_STATUS_OK;
1195 } 1201 }
1196 1202
1197 } // namespace sync_file_system 1203 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_util.cc ('k') | chrome/browser/sync_file_system/local_file_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698