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

Side by Side Diff: chrome/browser/privacy_blacklist/blacklist_store.cc

Issue 155625: A build fix for GCC 4.3.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/privacy_blacklist/blacklist_store.h" 5 #include "chrome/browser/privacy_blacklist/blacklist_store.h"
6 6
7 #include <cstdio> 7 #include <cstdio>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 11
12 namespace { 12 namespace {
13 13
14 const char cookie[] = "GCPBL100"; 14 const char cookie[] = "GCPBL100";
15 15
16 // This is a wrapper function for fwrite() to avoid warnings of GCC 4.4.
17 void WriteData(const char* data, size_t size, size_t items, FILE* stream) {
18 if (fwrite(data, size, items, stream) != size * items)
19 return;
Evan Martin 2009/07/17 17:15:49 Should this LOG(WARNING) ?
20 }
21
16 } 22 }
17 23
18 void BlacklistStoreOutput::WriteUInt(uint32 i) { 24 void BlacklistStoreOutput::WriteUInt(uint32 i) {
19 fwrite(reinterpret_cast<char*>(&i), 1, sizeof(uint32), file_); 25 WriteData(reinterpret_cast<char*>(&i), 1, sizeof(uint32), file_);
20 } 26 }
21 27
22 void BlacklistStoreOutput::WriteString(const std::string& s) { 28 void BlacklistStoreOutput::WriteString(const std::string& s) {
23 uint32 n = s.size(); 29 uint32 n = s.size();
24 fwrite(reinterpret_cast<char*>(&n), 1, sizeof(uint32), file_); 30 WriteData(reinterpret_cast<char*>(&n), 1, sizeof(uint32), file_);
25 fwrite(s.c_str(), 1, s.size(), file_); 31 WriteData(s.c_str(), 1, s.size(), file_);
26 } 32 }
27 33
28 BlacklistStoreOutput::BlacklistStoreOutput(FILE* file) : file_(file) { 34 BlacklistStoreOutput::BlacklistStoreOutput(FILE* file) : file_(file) {
29 fwrite(cookie, 1, sizeof(cookie), file_); 35 WriteData(cookie, 1, sizeof(cookie), file_);
30 } 36 }
31 37
32 BlacklistStoreOutput::~BlacklistStoreOutput() { 38 BlacklistStoreOutput::~BlacklistStoreOutput() {
33 file_util::CloseFile(file_); 39 file_util::CloseFile(file_);
34 } 40 }
35 41
36 void BlacklistStoreOutput::ReserveProviders(uint32 num) { 42 void BlacklistStoreOutput::ReserveProviders(uint32 num) {
37 WriteUInt(num); 43 WriteUInt(num);
38 } 44 }
39 45
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::vector<std::string>* types, 111 std::vector<std::string>* types,
106 uint32* provider) { 112 uint32* provider) {
107 *pattern = ReadString(); 113 *pattern = ReadString();
108 *attributes = ReadUInt(); 114 *attributes = ReadUInt();
109 if (uint32 n = ReadUInt()) { 115 if (uint32 n = ReadUInt()) {
110 while (n--) 116 while (n--)
111 types->push_back(ReadString()); 117 types->push_back(ReadString());
112 } 118 }
113 *provider = ReadUInt(); 119 *provider = ReadUInt();
114 } 120 }
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