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

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

Issue 4146004: ThreadRestrictions: disallow blocking IO on the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 10 years, 1 month 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
« base/nss_util.cc ('K') | « chrome/browser/spellcheck_host.cc ('k') | 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) 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 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/process_util.h" 20 #include "base/process_util.h"
21 #include "base/rand_util.h" 21 #include "base/rand_util.h"
22 #include "base/stack_container.h" 22 #include "base/stack_container.h"
23 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/thread_restrictions.h"
24 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_thread.h" 26 #include "chrome/browser/browser_thread.h"
26 #include "chrome/browser/history/history.h" 27 #include "chrome/browser/history/history.h"
27 #include "chrome/browser/profile.h" 28 #include "chrome/browser/profile.h"
28 29
29 using file_util::ScopedFILE; 30 using file_util::ScopedFILE;
30 using file_util::OpenFile; 31 using file_util::OpenFile;
31 using file_util::TruncateFile; 32 using file_util::TruncateFile;
32 33
33 const int32 VisitedLinkMaster::kFileHeaderSignatureOffset = 0; 34 const int32 VisitedLinkMaster::kFileHeaderSignatureOffset = 0;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 history_service_override_ = NULL; 245 history_service_override_ = NULL;
245 suppress_rebuild_ = false; 246 suppress_rebuild_ = false;
246 profile_ = profile; 247 profile_ = profile;
247 248
248 #ifndef NDEBUG 249 #ifndef NDEBUG
249 posted_asynchronous_operation_ = false; 250 posted_asynchronous_operation_ = false;
250 #endif 251 #endif
251 } 252 }
252 253
253 bool VisitedLinkMaster::Init() { 254 bool VisitedLinkMaster::Init() {
255 // We probably shouldn't be loading this from the UI thread,
256 // but it does need to happen early on in startup.
257 // http://code.google.com/p/chromium/issues/detail?id=24163
258 base::ThreadRestrictions::ScopedAllowIO allow_io;
254 if (!InitFromFile()) 259 if (!InitFromFile())
255 return InitFromScratch(suppress_rebuild_); 260 return InitFromScratch(suppress_rebuild_);
256 return true; 261 return true;
257 } 262 }
258 263
259 VisitedLinkMaster::Hash VisitedLinkMaster::TryToAddURL(const GURL& url) { 264 VisitedLinkMaster::Hash VisitedLinkMaster::TryToAddURL(const GURL& url) {
260 // Extra check that we are not off the record. This should not happen. 265 // Extra check that we are not off the record. This should not happen.
261 if (profile_ && profile_->IsOffTheRecord()) { 266 if (profile_ && profile_->IsOffTheRecord()) {
262 NOTREACHED(); 267 NOTREACHED();
263 return null_hash_; 268 return null_hash_;
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 AddFingerprint(*i, false); 887 AddFingerprint(*i, false);
883 added_since_rebuild_.clear(); 888 added_since_rebuild_.clear();
884 889
885 // Now handle deletions. 890 // Now handle deletions.
886 DeleteFingerprintsFromCurrentTable(deleted_since_rebuild_); 891 DeleteFingerprintsFromCurrentTable(deleted_since_rebuild_);
887 deleted_since_rebuild_.clear(); 892 deleted_since_rebuild_.clear();
888 893
889 // Send an update notification to all child processes. 894 // Send an update notification to all child processes.
890 listener_->NewTable(shared_memory_); 895 listener_->NewTable(shared_memory_);
891 896
897 // We shouldn't be writing the table from the main thread!
898 // http://code.google.com/p/chromium/issues/detail?id=24163
899 base::ThreadRestrictions::ScopedAllowIO allow_io;
892 WriteFullTable(); 900 WriteFullTable();
893 } 901 }
894 } 902 }
895 table_builder_ = NULL; // Will release our reference to the builder. 903 table_builder_ = NULL; // Will release our reference to the builder.
896 904
897 // Notify the unit test that the rebuild is complete (will be NULL in prod.) 905 // Notify the unit test that the rebuild is complete (will be NULL in prod.)
898 if (rebuild_complete_task_.get()) { 906 if (rebuild_complete_task_.get()) {
899 rebuild_complete_task_->Run(); 907 rebuild_complete_task_->Run();
900 rebuild_complete_task_.reset(NULL); 908 rebuild_complete_task_.reset(NULL);
901 } 909 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 } 1000 }
993 1001
994 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { 1002 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
995 if (master_) 1003 if (master_)
996 master_->OnTableRebuildComplete(success_, fingerprints_); 1004 master_->OnTableRebuildComplete(success_, fingerprints_);
997 1005
998 // WILL (generally) DELETE THIS! This balances the AddRef in 1006 // WILL (generally) DELETE THIS! This balances the AddRef in
999 // VisitedLinkMaster::RebuildTableFromHistory. 1007 // VisitedLinkMaster::RebuildTableFromHistory.
1000 Release(); 1008 Release();
1001 } 1009 }
OLDNEW
« base/nss_util.cc ('K') | « chrome/browser/spellcheck_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698