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

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

Issue 113169: Move win_util.h from common to app. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/toolbar_view.cc ('k') | chrome/chrome.gyp » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_master.h" 5 #include "chrome/browser/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>
11 #endif // defined(OS_WIN) 11 #endif // defined(OS_WIN)
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #if defined(OS_WIN)
17 #include "app/win_util.h"
18 #endif
16 #include "base/file_util.h" 19 #include "base/file_util.h"
17 #include "base/logging.h" 20 #include "base/logging.h"
18 #include "base/message_loop.h" 21 #include "base/message_loop.h"
19 #include "base/path_service.h" 22 #include "base/path_service.h"
20 #include "base/process_util.h" 23 #include "base/process_util.h"
21 #include "base/rand_util.h" 24 #include "base/rand_util.h"
22 #include "base/stack_container.h" 25 #include "base/stack_container.h"
23 #include "base/string_util.h" 26 #include "base/string_util.h"
24 #include "base/thread.h" 27 #include "base/thread.h"
25 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/history/history.h" 29 #include "chrome/browser/history/history.h"
27 #include "chrome/browser/profile.h" 30 #include "chrome/browser/profile.h"
28 #if defined(OS_WIN)
29 #include "chrome/common/win_util.h"
30 #endif
31 31
32 using file_util::ScopedFILE; 32 using file_util::ScopedFILE;
33 using file_util::OpenFile; 33 using file_util::OpenFile;
34 using file_util::TruncateFile; 34 using file_util::TruncateFile;
35 35
36 const int32 VisitedLinkMaster::kFileHeaderSignatureOffset = 0; 36 const int32 VisitedLinkMaster::kFileHeaderSignatureOffset = 0;
37 const int32 VisitedLinkMaster::kFileHeaderVersionOffset = 4; 37 const int32 VisitedLinkMaster::kFileHeaderVersionOffset = 4;
38 const int32 VisitedLinkMaster::kFileHeaderLengthOffset = 8; 38 const int32 VisitedLinkMaster::kFileHeaderLengthOffset = 8;
39 const int32 VisitedLinkMaster::kFileHeaderUsedOffset = 12; 39 const int32 VisitedLinkMaster::kFileHeaderUsedOffset = 12;
40 const int32 VisitedLinkMaster::kFileHeaderSaltOffset = 16; 40 const int32 VisitedLinkMaster::kFileHeaderSaltOffset = 16;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 off_t offset, 88 off_t offset,
89 const void* data, 89 const void* data,
90 size_t data_len) { 90 size_t data_len) {
91 if (fseek(file, offset, SEEK_SET) != 0) 91 if (fseek(file, offset, SEEK_SET) != 0)
92 return false; // Don't write to an invalid part of the file. 92 return false; // Don't write to an invalid part of the file.
93 93
94 size_t num_written = fwrite(data, 1, data_len, file); 94 size_t num_written = fwrite(data, 1, data_len, file);
95 95
96 // The write may not make it to the kernel (stdlib may buffer the write) 96 // The write may not make it to the kernel (stdlib may buffer the write)
97 // until the next fseek/fclose call. If we crash, it's easy for our used 97 // until the next fseek/fclose call. If we crash, it's easy for our used
98 // item count to be out of sync with the number of hashes we write. 98 // item count to be out of sync with the number of hashes we write.
99 // Protect against this by calling fflush. 99 // Protect against this by calling fflush.
100 int ret = fflush(file); 100 int ret = fflush(file);
101 DCHECK_EQ(0, ret); 101 DCHECK_EQ(0, ret);
102 return num_written == data_len; 102 return num_written == data_len;
103 } 103 }
104 104
105 private: 105 private:
106 // The data to write and where to write it. 106 // The data to write and where to write it.
107 FILE* file_; 107 FILE* file_;
108 int32 offset_; // Offset from the beginning of the file. 108 int32 offset_; // Offset from the beginning of the file.
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 } 1019 }
1020 1020
1021 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { 1021 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
1022 if (master_) 1022 if (master_)
1023 master_->OnTableRebuildComplete(success_, fingerprints_); 1023 master_->OnTableRebuildComplete(success_, fingerprints_);
1024 1024
1025 // WILL (generally) DELETE THIS! This balances the AddRef in 1025 // WILL (generally) DELETE THIS! This balances the AddRef in
1026 // VisitedLinkMaster::RebuildTableFromHistory. 1026 // VisitedLinkMaster::RebuildTableFromHistory.
1027 Release(); 1027 Release();
1028 } 1028 }
OLDNEW
« no previous file with comments | « chrome/browser/views/toolbar_view.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698