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

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

Issue 199065: Revert r25770 due to valgrind failures on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « base/thread.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 // The history system runs on a background thread so that potentially slow 5 // The history system runs on a background thread so that potentially slow
6 // database operations don't delay the browser. This backend processing is 6 // database operations don't delay the browser. This backend processing is
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to
8 // that thread. 8 // that thread.
9 // 9 //
10 // Main thread History thread 10 // Main thread History thread
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/autocomplete/history_url_provider.h" 33 #include "chrome/browser/autocomplete/history_url_provider.h"
34 #include "chrome/browser/browser_list.h" 34 #include "chrome/browser/browser_list.h"
35 #include "chrome/browser/browser_process.h" 35 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/browser_window.h" 36 #include "chrome/browser/browser_window.h"
37 #include "chrome/browser/chrome_thread.h" 37 #include "chrome/browser/chrome_thread.h"
38 #include "chrome/browser/history/download_types.h" 38 #include "chrome/browser/history/download_types.h"
39 #include "chrome/browser/history/history_backend.h" 39 #include "chrome/browser/history/history_backend.h"
40 #include "chrome/browser/history/history_types.h" 40 #include "chrome/browser/history/history_types.h"
41 #include "chrome/browser/history/in_memory_database.h" 41 #include "chrome/browser/history/in_memory_database.h"
42 #include "chrome/browser/history/in_memory_history_backend.h" 42 #include "chrome/browser/history/in_memory_history_backend.h"
43 #include "chrome/browser/history/visit_log.h"
44 #include "chrome/browser/profile.h" 43 #include "chrome/browser/profile.h"
45 #include "chrome/browser/visitedlink_master.h" 44 #include "chrome/browser/visitedlink_master.h"
46 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
47 #include "chrome/common/notification_service.h" 46 #include "chrome/common/notification_service.h"
48 #include "chrome/common/thumbnail_score.h" 47 #include "chrome/common/thumbnail_score.h"
49 #include "chrome/common/url_constants.h" 48 #include "chrome/common/url_constants.h"
50 #include "grit/chromium_strings.h" 49 #include "grit/chromium_strings.h"
51 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
52 #include "third_party/skia/include/core/SkBitmap.h" 51 #include "third_party/skia/include/core/SkBitmap.h"
53 52
54 using base::Time; 53 using base::Time;
55 using history::HistoryBackend; 54 using history::HistoryBackend;
56 55
57 namespace { 56 static const char* kHistoryThreadName = "Chrome_HistoryThread";
58
59 class ChromeHistoryThread : public ChromeThread {
60 public:
61 ChromeHistoryThread() : ChromeThread(ChromeThread::HISTORY) {}
62 virtual ~ChromeHistoryThread() {
63 // We cannot rely on our base class to call Stop() in case we want our
64 // CleanUp function to run.
65 Stop();
66 }
67 protected:
68 virtual void Run(MessageLoop* message_loop) {
69 // Allocate VisitLog on local stack so it will be saved in crash dump.
70 history::VisitLog visit_log;
71 history::InitVisitLog(&visit_log);
72 message_loop->Run();
73 }
74 };
75
76 } // namespace
77 57
78 // Sends messages from the backend to us on the main thread. This must be a 58 // Sends messages from the backend to us on the main thread. This must be a
79 // separate class from the history service so that it can hold a reference to 59 // separate class from the history service so that it can hold a reference to
80 // the history service (otherwise we would have to manually AddRef and 60 // the history service (otherwise we would have to manually AddRef and
81 // Release when the Backend has a reference to us). 61 // Release when the Backend has a reference to us).
82 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { 62 class HistoryService::BackendDelegate : public HistoryBackend::Delegate {
83 public: 63 public:
84 explicit BackendDelegate(HistoryService* history_service) 64 explicit BackendDelegate(HistoryService* history_service)
85 : history_service_(history_service), 65 : history_service_(history_service),
86 message_loop_(MessageLoop::current()) { 66 message_loop_(MessageLoop::current()) {
(...skipping 26 matching lines...) Expand all
113 93
114 private: 94 private:
115 scoped_refptr<HistoryService> history_service_; 95 scoped_refptr<HistoryService> history_service_;
116 MessageLoop* message_loop_; 96 MessageLoop* message_loop_;
117 }; 97 };
118 98
119 // static 99 // static
120 const history::StarID HistoryService::kBookmarkBarID = 1; 100 const history::StarID HistoryService::kBookmarkBarID = 1;
121 101
122 HistoryService::HistoryService() 102 HistoryService::HistoryService()
123 : thread_(new ChromeHistoryThread()), 103 : thread_(new base::Thread(kHistoryThreadName)),
124 profile_(NULL), 104 profile_(NULL),
125 backend_loaded_(false) { 105 backend_loaded_(false) {
126 // Is NULL when running generate_profile. 106 // Is NULL when running generate_profile.
127 if (NotificationService::current()) { 107 if (NotificationService::current()) {
128 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 108 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
129 Source<Profile>(profile_)); 109 Source<Profile>(profile_));
130 } 110 }
131 } 111 }
132 112
133 HistoryService::HistoryService(Profile* profile) 113 HistoryService::HistoryService(Profile* profile)
134 : thread_(new ChromeHistoryThread()), 114 : thread_(new base::Thread(kHistoryThreadName)),
135 profile_(profile), 115 profile_(profile),
136 backend_loaded_(false) { 116 backend_loaded_(false) {
137 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 117 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
138 Source<Profile>(profile_)); 118 Source<Profile>(profile_));
139 } 119 }
140 120
141 HistoryService::~HistoryService() { 121 HistoryService::~HistoryService() {
142 // Shutdown the backend. This does nothing if Cleanup was already invoked. 122 // Shutdown the backend. This does nothing if Cleanup was already invoked.
143 Cleanup(); 123 Cleanup();
144 } 124 }
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 NotificationService::current()->Notify(type, source, det); 665 NotificationService::current()->Notify(type, source, det);
686 } 666 }
687 667
688 void HistoryService::OnDBLoaded() { 668 void HistoryService::OnDBLoaded() {
689 LOG(INFO) << "History backend finished loading"; 669 LOG(INFO) << "History backend finished loading";
690 backend_loaded_ = true; 670 backend_loaded_ = true;
691 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, 671 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED,
692 Source<Profile>(profile_), 672 Source<Profile>(profile_),
693 Details<HistoryService>(this)); 673 Details<HistoryService>(this));
694 } 674 }
OLDNEW
« no previous file with comments | « base/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698