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

Side by Side Diff: chrome/browser/visitedlink/visitedlink_master.cc

Issue 10826297: Fix error checking in VisitedLinkMaster. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: 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
« 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 "chrome/browser/visitedlink/visitedlink_master.h" 5 #include "chrome/browser/visitedlink/visitedlink_master.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <io.h> 9 #include <io.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 int ret = fflush(file); 87 int ret = fflush(file);
88 DCHECK_EQ(0, ret); 88 DCHECK_EQ(0, ret);
89 return num_written == data_len; 89 return num_written == data_len;
90 } 90 }
91 91
92 // This task executes on a background thread and executes a write. This 92 // This task executes on a background thread and executes a write. This
93 // prevents us from blocking the UI thread doing I/O. Double pointer to FILE 93 // prevents us from blocking the UI thread doing I/O. Double pointer to FILE
94 // is used because file may still not be opened by the time of scheduling 94 // is used because file may still not be opened by the time of scheduling
95 // the task for execution. 95 // the task for execution.
96 void AsyncWrite(FILE** file, int32 offset, const std::string& data) { 96 void AsyncWrite(FILE** file, int32 offset, const std::string& data) {
97 WriteToFile(*file, offset, data.data(), data.size()); 97 if (*file)
98 WriteToFile(*file, offset, data.data(), data.size());
98 } 99 }
99 100
100 // Truncates the file to the current position asynchronously on a background 101 // Truncates the file to the current position asynchronously on a background
101 // thread. Double pointer to FILE is used because file may still not be opened 102 // thread. Double pointer to FILE is used because file may still not be opened
102 // by the time of scheduling the task for execution. 103 // by the time of scheduling the task for execution.
103 void AsyncTruncate(FILE** file) { 104 void AsyncTruncate(FILE** file) {
104 base::IgnoreResult(TruncateFile(*file)); 105 if (*file)
106 base::IgnoreResult(TruncateFile(*file));
105 } 107 }
106 108
107 // Closes the file on a background thread and releases memory used for storage 109 // Closes the file on a background thread and releases memory used for storage
108 // of FILE* value. Double pointer to FILE is used because file may still not 110 // of FILE* value. Double pointer to FILE is used because file may still not
109 // be opened by the time of scheduling the task for execution. 111 // be opened by the time of scheduling the task for execution.
110 void AsyncClose(FILE** file) { 112 void AsyncClose(FILE** file) {
111 base::IgnoreResult(fclose(*file)); 113 if (*file)
114 base::IgnoreResult(fclose(*file));
112 free(file); 115 free(file);
113 } 116 }
114 117
115 } // namespace 118 } // namespace
116 119
117 // TableBuilder --------------------------------------------------------------- 120 // TableBuilder ---------------------------------------------------------------
118 121
119 // How rebuilding from history works 122 // How rebuilding from history works
120 // --------------------------------- 123 // ---------------------------------
121 // 124 //
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 } 976 }
974 977
975 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { 978 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
976 if (master_) 979 if (master_)
977 master_->OnTableRebuildComplete(success_, fingerprints_); 980 master_->OnTableRebuildComplete(success_, fingerprints_);
978 981
979 // WILL (generally) DELETE THIS! This balances the AddRef in 982 // WILL (generally) DELETE THIS! This balances the AddRef in
980 // VisitedLinkMaster::RebuildTableFromHistory. 983 // VisitedLinkMaster::RebuildTableFromHistory.
981 Release(); 984 Release();
982 } 985 }
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