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

Unified Diff: chrome/browser/instant/instant_service.cc

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Charlie's comments. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_service.cc
diff --git a/chrome/browser/instant/instant_service.cc b/chrome/browser/instant/instant_service.cc
index 1f6de61da8150c847bcfc756b650edf630a94983..daf7d1bc40558ddba93ffa16d43f12cf8cd1bf02 100644
--- a/chrome/browser/instant/instant_service.cc
+++ b/chrome/browser/instant/instant_service.cc
@@ -4,14 +4,24 @@
#include "chrome/browser/instant/instant_service.h"
+#include "chrome/browser/instant/instant_io_context.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/url_data_source.h"
-InstantService::InstantService() {
+using content::BrowserThread;
+
+InstantService::InstantService(Profile* profile)
+ : profile_(profile) {
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
+ content::URLDataSource::Add(profile, new ThumbnailSource(profile));
}
InstantService::~InstantService() {
@@ -19,6 +29,13 @@ InstantService::~InstantService() {
void InstantService::AddInstantProcess(int process_id) {
process_ids_.insert(process_id);
+
+ if (profile_ && profile_->GetResourceContext()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::AddInstantProcessOnIO,
+ profile_->GetResourceContext(), process_id));
+ }
}
bool InstantService::IsInstantProcess(int process_id) const {
@@ -27,11 +44,26 @@ bool InstantService::IsInstantProcess(int process_id) const {
void InstantService::Shutdown() {
process_ids_.clear();
+
+ if (profile_ && profile_->GetResourceContext()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::ClearInstantProcessesOnIO,
+ profile_->GetResourceContext()));
+ }
}
void InstantService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
+ DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED);
int process_id = content::Source<content::RenderProcessHost>(source)->GetID();
process_ids_.erase(process_id);
+
+ if (profile_ && profile_->GetResourceContext()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::RemoveInstantProcessOnIO,
+ profile_->GetResourceContext(), process_id));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698