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

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

Issue 2442453002: [Sync] Adds a new switch for enabling the new local server backend. (Closed)
Patch Set: Ifdefs for Windows only. Created 4 years, 2 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 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 CHECK(base::CreateDirectory(filename.DirName()));
pavely 2016/10/27 23:53:39 Failure to create directory is the same as failure
pastarmovj 2016/11/02 13:39:25 Agree and it should not crash for this reason imho
526 int result = base::WriteFile(filename, serialized.data(), serialized.size()); 527 int result = base::WriteFile(filename, serialized.data(), serialized.size());
527 return result == static_cast<int>(serialized.size()); 528 return result == static_cast<int>(serialized.size());
528 } 529 }
529 530
530 // Loads all entities and server state from a protobuf file in |filename|. 531 // Loads all entities and server state from a protobuf file in |filename|.
531 bool LoopbackServer::LoadStateFromFile(const base::FilePath& filename) { 532 bool LoopbackServer::LoadStateFromFile(const base::FilePath& filename) {
532 if (base::PathExists(filename)) { 533 if (base::PathExists(filename)) {
533 std::string serialized; 534 std::string serialized;
534 if (base::ReadFileToString(filename, &serialized)) { 535 if (base::ReadFileToString(filename, &serialized)) {
535 sync_pb::LoopbackServerProto proto; 536 sync_pb::LoopbackServerProto proto;
(...skipping 11 matching lines...) Expand all
547 // write. 548 // write.
548 LOG(ERROR) << "Loopback sync can not read the persistent state file."; 549 LOG(ERROR) << "Loopback sync can not read the persistent state file.";
549 return false; 550 return false;
550 } 551 }
551 } 552 }
552 LOG(WARNING) << "Loopback sync persistent state file does not exist."; 553 LOG(WARNING) << "Loopback sync persistent state file does not exist.";
553 return false; 554 return false;
554 } 555 }
555 556
556 } // namespace syncer 557 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698