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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/download_metadata_manager.cc

Issue 1127963002: Implement lossy pref behavior for JsonPrefStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs-fix-flags
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/safe_browsing/incident_reporting/download_metadata_mana ger.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/download_metadata_mana ger.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 UMA_HISTOGRAM_ENUMERATION( 101 UMA_HISTOGRAM_ENUMERATION(
102 "SBIRS.DownloadMetadata.ReadResult", result, NUM_READ_RESULTS); 102 "SBIRS.DownloadMetadata.ReadResult", result, NUM_READ_RESULTS);
103 } 103 }
104 104
105 // Writes |download_metadata| to |metadata_path|. 105 // Writes |download_metadata| to |metadata_path|.
106 void WriteMetadataOnWorkerPool(const base::FilePath& metadata_path, 106 void WriteMetadataOnWorkerPool(const base::FilePath& metadata_path,
107 DownloadMetadata* download_metadata) { 107 DownloadMetadata* download_metadata) {
108 MetadataWriteResult result = NUM_WRITE_RESULTS; 108 MetadataWriteResult result = NUM_WRITE_RESULTS;
109 std::string file_data; 109 std::string file_data;
110 if (download_metadata->SerializeToString(&file_data)) { 110 if (download_metadata->SerializeToString(&file_data)) {
111 result = 111 result = base::ImportantFileWriterImpl::WriteFileAtomically(metadata_path,
112 base::ImportantFileWriter::WriteFileAtomically(metadata_path, file_data) 112 file_data)
113 ? WRITE_SUCCESS 113 ? WRITE_SUCCESS
114 : WRITE_FAILURE; 114 : WRITE_FAILURE;
115 } else { 115 } else {
116 result = SERIALIZATION_FAILURE; 116 result = SERIALIZATION_FAILURE;
117 } 117 }
118 UMA_HISTOGRAM_ENUMERATION( 118 UMA_HISTOGRAM_ENUMERATION(
119 "SBIRS.DownloadMetadata.WriteResult", result, NUM_WRITE_RESULTS); 119 "SBIRS.DownloadMetadata.WriteResult", result, NUM_WRITE_RESULTS);
120 } 120 }
121 121
122 // Deletes |metadata_path|. 122 // Deletes |metadata_path|.
123 void DeleteMetadataOnWorkerPool(const base::FilePath& metadata_path) { 123 void DeleteMetadataOnWorkerPool(const base::FilePath& metadata_path) {
124 bool success = base::DeleteFile(metadata_path, false /* not recursive */); 124 bool success = base::DeleteFile(metadata_path, false /* not recursive */);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 622
623 void DownloadMetadataManager::ManagerContext::WriteMetadata() { 623 void DownloadMetadataManager::ManagerContext::WriteMetadata() {
624 write_runner_->PostTask( 624 write_runner_->PostTask(
625 FROM_HERE, 625 FROM_HERE,
626 base::Bind(&WriteMetadataOnWorkerPool, 626 base::Bind(&WriteMetadataOnWorkerPool,
627 metadata_path_, 627 metadata_path_,
628 base::Owned(new DownloadMetadata(*download_metadata_)))); 628 base::Owned(new DownloadMetadata(*download_metadata_))));
629 } 629 }
630 630
631 } // namespace safe_browsing 631 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698