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

Side by Side Diff: sync/syncable/on_disk_directory_backing_store.cc

Issue 10827212: Fix mem leak in DirectoryBackingStore unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rewrite fix Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/syncable/on_disk_directory_backing_store.h" 5 #include "sync/syncable/on_disk_directory_backing_store.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "sync/syncable/syncable-inl.h" 10 #include "sync/syncable/syncable-inl.h"
10 11
11 namespace syncer { 12 namespace syncer {
12 namespace syncable { 13 namespace syncable {
13 14
14 namespace { 15 namespace {
15 16
16 enum HistogramResultEnum { 17 enum HistogramResultEnum {
17 FIRST_TRY_SUCCESS, 18 FIRST_TRY_SUCCESS,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (result == OPENED) { 66 if (result == OPENED) {
66 HISTOGRAM_ENUMERATION( 67 HISTOGRAM_ENUMERATION(
67 "Sync.DirectoryOpenResult", FIRST_TRY_SUCCESS, RESULT_COUNT); 68 "Sync.DirectoryOpenResult", FIRST_TRY_SUCCESS, RESULT_COUNT);
68 return OPENED; 69 return OPENED;
69 } 70 }
70 71
71 ReportFirstTryOpenFailure(); 72 ReportFirstTryOpenFailure();
72 73
73 // The fallback: delete the current database and return a fresh one. We can 74 // The fallback: delete the current database and return a fresh one. We can
74 // fetch the user's data from the could. 75 // fetch the user's data from the could.
75 entry_bucket->clear(); 76 STLDeleteElements(entry_bucket);
76 db_.reset(new sql::Connection); 77 db_.reset(new sql::Connection);
77 file_util::Delete(backing_filepath_, false); 78 file_util::Delete(backing_filepath_, false);
78 79
79 result = TryLoad(entry_bucket, kernel_load_info); 80 result = TryLoad(entry_bucket, kernel_load_info);
80 if (result == OPENED) { 81 if (result == OPENED) {
81 HISTOGRAM_ENUMERATION( 82 HISTOGRAM_ENUMERATION(
82 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT); 83 "Sync.DirectoryOpenResult", SECOND_TRY_SUCCESS, RESULT_COUNT);
83 } else { 84 } else {
84 HISTOGRAM_ENUMERATION( 85 HISTOGRAM_ENUMERATION(
85 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT); 86 "Sync.DirectoryOpenResult", SECOND_TRY_FAILURE, RESULT_COUNT);
86 } 87 }
87 88
88 return result; 89 return result;
89 } 90 }
90 91
91 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() { 92 void OnDiskDirectoryBackingStore::ReportFirstTryOpenFailure() {
92 // In debug builds, the last thing we want is to silently clear the database. 93 // In debug builds, the last thing we want is to silently clear the database.
93 // It's full of evidence that might help us determine what went wrong. It 94 // It's full of evidence that might help us determine what went wrong. It
94 // might be sqlite's fault, but it could also be a bug in sync. We crash 95 // might be sqlite's fault, but it could also be a bug in sync. We crash
95 // immediately so a developer can investigate. 96 // immediately so a developer can investigate.
96 // 97 //
97 // Developers: If you're not interested in debugging this right now, just move 98 // Developers: If you're not interested in debugging this right now, just move
98 // aside the 'Sync Data' directory in your profile. This is similar to what 99 // aside the 'Sync Data' directory in your profile. This is similar to what
99 // the code would do if this DCHECK were disabled. 100 // the code would do if this DCHECK were disabled.
100 NOTREACHED() << "Crashing to preserve corrupt sync database"; 101 NOTREACHED() << "Crashing to preserve corrupt sync database";
101 } 102 }
102 103
103 } // namespace syncable 104 } // namespace syncable
104 } // namespace syncer 105 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698