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

Side by Side Diff: components/sync/engine_impl/loopback_server/loopback_server.cc

Issue 2473613003: [Sync] Adds a new switch for enabling the new local server backend. (Closed)
Patch Set: Ifdef protect the variable. Created 4 years, 1 month 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
« no previous file with comments | « components/sync/engine/sync_manager.cc ('k') | components/sync/engine_impl/sync_manager_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/sync/engine_impl/loopback_server/loopback_server.h" 5 #include "components/sync/engine_impl/loopback_server/loopback_server.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 516
517 return true; 517 return true;
518 } 518 }
519 519
520 // Saves all entities and server state to a protobuf file in |filename|. 520 // Saves all entities and server state to a protobuf file in |filename|.
521 bool LoopbackServer::SaveStateToFile(const base::FilePath& filename) const { 521 bool LoopbackServer::SaveStateToFile(const base::FilePath& filename) const {
522 sync_pb::LoopbackServerProto proto; 522 sync_pb::LoopbackServerProto proto;
523 SerializeState(&proto); 523 SerializeState(&proto);
524 524
525 std::string serialized = proto.SerializeAsString(); 525 std::string serialized = proto.SerializeAsString();
526 if (!base::CreateDirectory(filename.DirName())) {
527 LOG(ERROR) << "Loopback sync could not create the storage directory.";
528 return false;
529 }
526 int result = base::WriteFile(filename, serialized.data(), serialized.size()); 530 int result = base::WriteFile(filename, serialized.data(), serialized.size());
527 return result == static_cast<int>(serialized.size()); 531 return result == static_cast<int>(serialized.size());
528 } 532 }
529 533
530 // Loads all entities and server state from a protobuf file in |filename|. 534 // Loads all entities and server state from a protobuf file in |filename|.
531 bool LoopbackServer::LoadStateFromFile(const base::FilePath& filename) { 535 bool LoopbackServer::LoadStateFromFile(const base::FilePath& filename) {
532 if (base::PathExists(filename)) { 536 if (base::PathExists(filename)) {
533 std::string serialized; 537 std::string serialized;
534 if (base::ReadFileToString(filename, &serialized)) { 538 if (base::ReadFileToString(filename, &serialized)) {
535 sync_pb::LoopbackServerProto proto; 539 sync_pb::LoopbackServerProto proto;
(...skipping 11 matching lines...) Expand all
547 // write. 551 // write.
548 LOG(ERROR) << "Loopback sync can not read the persistent state file."; 552 LOG(ERROR) << "Loopback sync can not read the persistent state file.";
549 return false; 553 return false;
550 } 554 }
551 } 555 }
552 LOG(WARNING) << "Loopback sync persistent state file does not exist."; 556 LOG(WARNING) << "Loopback sync persistent state file does not exist.";
553 return false; 557 return false;
554 } 558 }
555 559
556 } // namespace syncer 560 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/sync_manager.cc ('k') | components/sync/engine_impl/sync_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698