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

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

Issue 194067: Retry 25770 after fixing Valgrind issue.... (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') | chrome/browser/history/visit_log.h » ('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 // 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"
43 #include "chrome/browser/profile.h" 44 #include "chrome/browser/profile.h"
44 #include "chrome/browser/visitedlink_master.h" 45 #include "chrome/browser/visitedlink_master.h"
45 #include "chrome/common/chrome_constants.h" 46 #include "chrome/common/chrome_constants.h"
46 #include "chrome/common/notification_service.h" 47 #include "chrome/common/notification_service.h"
47 #include "chrome/common/thumbnail_score.h" 48 #include "chrome/common/thumbnail_score.h"
48 #include "chrome/common/url_constants.h" 49 #include "chrome/common/url_constants.h"
49 #include "grit/chromium_strings.h" 50 #include "grit/chromium_strings.h"
50 #include "grit/generated_resources.h" 51 #include "grit/generated_resources.h"
51 #include "third_party/skia/include/core/SkBitmap.h" 52 #include "third_party/skia/include/core/SkBitmap.h"
52 53
53 using base::Time; 54 using base::Time;
54 using history::HistoryBackend; 55 using history::HistoryBackend;
55 56
56 static const char* kHistoryThreadName = "Chrome_HistoryThread"; 57 namespace {
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() since we want our
64 // CleanUp function to run.
65 Stop();
66 }
67 protected:
68 virtual void CleanUp() {
69 history::ClearVisitLog();
70 }
71 virtual void Run(MessageLoop* message_loop) {
72 // Allocate VisitLog on local stack so it will be saved in crash dump.
73 history::VisitLog visit_log;
74 history::InitVisitLog(&visit_log);
75 message_loop->Run();
76 history::ClearVisitLog();
77 }
78 };
79
80 } // namespace
57 81
58 // Sends messages from the backend to us on the main thread. This must be a 82 // Sends messages from the backend to us on the main thread. This must be a
59 // separate class from the history service so that it can hold a reference to 83 // separate class from the history service so that it can hold a reference to
60 // the history service (otherwise we would have to manually AddRef and 84 // the history service (otherwise we would have to manually AddRef and
61 // Release when the Backend has a reference to us). 85 // Release when the Backend has a reference to us).
62 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { 86 class HistoryService::BackendDelegate : public HistoryBackend::Delegate {
63 public: 87 public:
64 explicit BackendDelegate(HistoryService* history_service) 88 explicit BackendDelegate(HistoryService* history_service)
65 : history_service_(history_service), 89 : history_service_(history_service),
66 message_loop_(MessageLoop::current()) { 90 message_loop_(MessageLoop::current()) {
(...skipping 26 matching lines...) Expand all
93 117
94 private: 118 private:
95 scoped_refptr<HistoryService> history_service_; 119 scoped_refptr<HistoryService> history_service_;
96 MessageLoop* message_loop_; 120 MessageLoop* message_loop_;
97 }; 121 };
98 122
99 // static 123 // static
100 const history::StarID HistoryService::kBookmarkBarID = 1; 124 const history::StarID HistoryService::kBookmarkBarID = 1;
101 125
102 HistoryService::HistoryService() 126 HistoryService::HistoryService()
103 : thread_(new base::Thread(kHistoryThreadName)), 127 : thread_(new ChromeHistoryThread()),
104 profile_(NULL), 128 profile_(NULL),
105 backend_loaded_(false) { 129 backend_loaded_(false) {
106 // Is NULL when running generate_profile. 130 // Is NULL when running generate_profile.
107 if (NotificationService::current()) { 131 if (NotificationService::current()) {
108 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 132 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
109 Source<Profile>(profile_)); 133 Source<Profile>(profile_));
110 } 134 }
111 } 135 }
112 136
113 HistoryService::HistoryService(Profile* profile) 137 HistoryService::HistoryService(Profile* profile)
114 : thread_(new base::Thread(kHistoryThreadName)), 138 : thread_(new ChromeHistoryThread()),
115 profile_(profile), 139 profile_(profile),
116 backend_loaded_(false) { 140 backend_loaded_(false) {
117 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 141 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
118 Source<Profile>(profile_)); 142 Source<Profile>(profile_));
119 } 143 }
120 144
121 HistoryService::~HistoryService() { 145 HistoryService::~HistoryService() {
122 // Shutdown the backend. This does nothing if Cleanup was already invoked. 146 // Shutdown the backend. This does nothing if Cleanup was already invoked.
123 Cleanup(); 147 Cleanup();
124 } 148 }
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 NotificationService::current()->Notify(type, source, det); 689 NotificationService::current()->Notify(type, source, det);
666 } 690 }
667 691
668 void HistoryService::OnDBLoaded() { 692 void HistoryService::OnDBLoaded() {
669 LOG(INFO) << "History backend finished loading"; 693 LOG(INFO) << "History backend finished loading";
670 backend_loaded_ = true; 694 backend_loaded_ = true;
671 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, 695 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED,
672 Source<Profile>(profile_), 696 Source<Profile>(profile_),
673 Details<HistoryService>(this)); 697 Details<HistoryService>(this));
674 } 698 }
OLDNEW
« no previous file with comments | « base/thread.cc ('k') | chrome/browser/history/visit_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698