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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database.cc

Issue 527163002: [SyncFS] Retry initialization of MetadataDatabase on failure of loading ServiceMetadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_backend/metadata_database.h" 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 DCHECK(create_param->worker_task_runner->RunsTasksOnCurrentThread()); 1421 DCHECK(create_param->worker_task_runner->RunsTasksOnCurrentThread());
1422 1422
1423 scoped_ptr<MetadataDatabase> metadata_database( 1423 scoped_ptr<MetadataDatabase> metadata_database(
1424 new MetadataDatabase(create_param->worker_task_runner, 1424 new MetadataDatabase(create_param->worker_task_runner,
1425 create_param->database_path, 1425 create_param->database_path,
1426 create_param->env_override)); 1426 create_param->env_override));
1427 SyncStatusCode status = metadata_database->Initialize(); 1427 SyncStatusCode status = metadata_database->Initialize();
1428 if (status != SYNC_STATUS_OK) 1428 if (status != SYNC_STATUS_OK)
1429 metadata_database.reset(); 1429 metadata_database.reset();
1430 1430
1431 metadata_database->DetachFromSequence(); 1431 if (metadata_database)
1432 metadata_database->DetachFromSequence();
1432 create_param->worker_task_runner->PostTask( 1433 create_param->worker_task_runner->PostTask(
1433 FROM_HERE, 1434 FROM_HERE,
1434 base::Bind( 1435 base::Bind(
1435 callback, status, base::Passed(&metadata_database))); 1436 callback, status, base::Passed(&metadata_database)));
1436 } 1437 }
1437 1438
1438 SyncStatusCode MetadataDatabase::Initialize() { 1439 SyncStatusCode MetadataDatabase::Initialize() {
1439 base::ThreadRestrictions::AssertIOAllowed(); 1440 base::ThreadRestrictions::AssertIOAllowed();
1440 DCHECK(worker_sequence_checker_.CalledOnValidSequencedThread()); 1441 DCHECK(worker_sequence_checker_.CalledOnValidSequencedThread());
1441 1442
(...skipping 11 matching lines...) Expand all
1453 if (status != SYNC_STATUS_OK) 1454 if (status != SYNC_STATUS_OK)
1454 return status; 1455 return status;
1455 } 1456 }
1456 1457
1457 if (CommandLine::ForCurrentProcess()->HasSwitch( 1458 if (CommandLine::ForCurrentProcess()->HasSwitch(
1458 kEnableMetadataDatabaseOnDisk)) { 1459 kEnableMetadataDatabaseOnDisk)) {
1459 index_ = MetadataDatabaseIndexOnDisk::Create(db_.get()); 1460 index_ = MetadataDatabaseIndexOnDisk::Create(db_.get());
1460 } else { 1461 } else {
1461 index_ = MetadataDatabaseIndex::Create(db_.get()); 1462 index_ = MetadataDatabaseIndex::Create(db_.get());
1462 } 1463 }
1464 if (!index_) {
1465 // Delete all entries in |db_| to reset it.
1466 scoped_ptr<LevelDBWrapper::Iterator> itr = db_->NewIterator();
1467 for (itr->SeekToFirst(); itr->Valid();)
1468 itr->Delete();
nhiroki 2014/09/02 08:36:25 Although not related to this CL and you don't have
peria 2014/09/03 04:08:13 Acknowledged.
1469 db_->Commit();
nhiroki 2014/09/02 07:26:04 If you want to delete all records, can you use lev
peria 2014/09/02 07:36:27 We have to update LevelDBWrapper class to use it :
nhiroki 2014/09/02 08:36:25 Okay, can we have a TODO comment about that?
peria 2014/09/03 04:08:13 Done.
1470
1471 return SYNC_DATABASE_ERROR_FAILED;
nhiroki 2014/09/02 07:26:04 Let me confirm... this makes the SyncFS disabled u
peria 2014/09/02 07:36:27 Yes, it is. We have to run SyncEngineInitializer a
nhiroki 2014/09/02 08:36:25 I see... there would be another option to retry th
peria 2014/09/03 04:08:13 Acknowledged.
1472 }
1463 1473
1464 status = LevelDBStatusToSyncStatusCode(db_->Commit()); 1474 status = LevelDBStatusToSyncStatusCode(db_->Commit());
1465 if (status != SYNC_STATUS_OK) 1475 if (status != SYNC_STATUS_OK)
1466 return status; 1476 return status;
1467 1477
1468 UpdateLargestKnownChangeID(index_->GetLargestChangeID()); 1478 UpdateLargestKnownChangeID(index_->GetLargestChangeID());
1469 1479
1470 return status; 1480 return status;
1471 } 1481 }
1472 1482
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 return false; 1964 return false;
1955 1965
1956 if (!parents.empty()) 1966 if (!parents.empty())
1957 return false; 1967 return false;
1958 1968
1959 return true; 1969 return true;
1960 } 1970 }
1961 1971
1962 } // namespace drive_backend 1972 } // namespace drive_backend
1963 } // namespace sync_file_system 1973 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698