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

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

Issue 9316109: Move Ownership of IMUI to HistoryService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/history/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
15 #include "base/file_util.h" 14 #include "base/file_util.h"
16 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
18 #include "base/message_loop.h" 17 #include "base/message_loop.h"
19 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
20 #include "base/string_util.h" 19 #include "base/string_util.h"
21 #include "base/time.h" 20 #include "base/time.h"
22 #include "chrome/browser/autocomplete/history_url_provider.h" 21 #include "chrome/browser/autocomplete/history_url_provider.h"
23 #include "chrome/browser/bookmarks/bookmark_service.h" 22 #include "chrome/browser/bookmarks/bookmark_service.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 delegate_->NotifyProfileError(id_, status); 572 delegate_->NotifyProfileError(id_, status);
574 db_.reset(); 573 db_.reset();
575 return; 574 return;
576 default: 575 default:
577 NOTREACHED(); 576 NOTREACHED();
578 } 577 }
579 578
580 // Fill the in-memory database and send it back to the history service on the 579 // Fill the in-memory database and send it back to the history service on the
581 // main thread. 580 // main thread.
582 InMemoryHistoryBackend* mem_backend = new InMemoryHistoryBackend; 581 InMemoryHistoryBackend* mem_backend = new InMemoryHistoryBackend;
583 if (mem_backend->Init(history_name, history_dir_, db_.get(), languages)) 582 if (mem_backend->Init(history_name, db_.get()))
584 delegate_->SetInMemoryBackend(id_, mem_backend); // Takes ownership of 583 delegate_->SetInMemoryBackend(id_, mem_backend); // Takes ownership of
585 // pointer. 584 // pointer.
586 else 585 else
587 delete mem_backend; // Error case, run without the in-memory DB. 586 delete mem_backend; // Error case, run without the in-memory DB.
588 db_->BeginExclusiveMode(); // Must be after the mem backend read the data. 587 db_->BeginExclusiveMode(); // Must be after the mem backend read the data.
589 588
590 // Create the history publisher which needs to be passed on to the text and 589 // Create the history publisher which needs to be passed on to the text and
591 // thumbnail databases for publishing history. 590 // thumbnail databases for publishing history.
592 history_publisher_.reset(new HistoryPublisher()); 591 history_publisher_.reset(new HistoryPublisher());
593 if (!history_publisher_->Init()) { 592 if (!history_publisher_->Init()) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // GetMostRecentRedirectsTo(url, &details->redirects); 754 // GetMostRecentRedirectsTo(url, &details->redirects);
756 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URL_VISITED, details); 755 BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URL_VISITED, details);
757 } else { 756 } else {
758 VLOG(0) << "Failed to build visit insert statement: " 757 VLOG(0) << "Failed to build visit insert statement: "
759 << "url_id = " << url_id; 758 << "url_id = " << url_id;
760 } 759 }
761 760
762 return std::make_pair(url_id, visit_id); 761 return std::make_pair(url_id, visit_id);
763 } 762 }
764 763
765 void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls, 764 void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls,
mrossetti 2012/02/04 00:38:38 FYI, I will change all of the std::vector<URLRow>'
766 VisitSource visit_source) { 765 VisitSource visit_source) {
767 if (!db_.get()) 766 if (!db_.get())
768 return; 767 return;
769 768
770 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails); 769 scoped_ptr<URLsModifiedDetails> modified(new URLsModifiedDetails);
771 for (std::vector<URLRow>::const_iterator i = urls.begin(); 770 for (std::vector<URLRow>::const_iterator i = urls.begin();
772 i != urls.end(); ++i) { 771 i != urls.end(); ++i) {
773 DCHECK(!i->last_visit().is_null()); 772 DCHECK(!i->last_visit().is_null());
774 773
775 // We will add to either the archived database or the main one depending on 774 // We will add to either the archived database or the main one depending on
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 break; 2314 break;
2316 } 2315 }
2317 } 2316 }
2318 } 2317 }
2319 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name 2318 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name
2320 TimeTicks::Now() - beginning_time); 2319 TimeTicks::Now() - beginning_time);
2321 return success; 2320 return success;
2322 } 2321 }
2323 2322
2324 } // namespace history 2323 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698