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

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: Yet another rebase Created 7 years, 9 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
« no previous file with comments | « chrome/browser/instant/instant_service.h ('k') | chrome/browser/instant/instant_service_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3c8a6b2ba2c9c93b4ca5f714d27175e4ffca84e8 100644
--- a/chrome/browser/instant/instant_service.cc
+++ b/chrome/browser/instant/instant_service.cc
@@ -4,14 +4,38 @@
#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"
+
+using content::BrowserThread;
+
+InstantService::InstantService(Profile* profile)
+ : profile_(profile) {
+ // Stub for unit tests.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
+ return;
-InstantService::InstantService() {
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllSources());
+
+ instant_io_context_ = new InstantIOContext();
+
+ if (profile_ && profile_->GetResourceContext()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::SetUserDataOnIO,
+ profile->GetResourceContext(), instant_io_context_));
+ }
+
+ content::URLDataSource::Add(profile, new ThumbnailSource(profile));
}
InstantService::~InstantService() {
@@ -19,6 +43,13 @@ InstantService::~InstantService() {
void InstantService::AddInstantProcess(int process_id) {
process_ids_.insert(process_id);
+
+ if (instant_io_context_) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::AddInstantProcessOnIO,
+ instant_io_context_, process_id));
+ }
}
bool InstantService::IsInstantProcess(int process_id) const {
@@ -27,11 +58,27 @@ bool InstantService::IsInstantProcess(int process_id) const {
void InstantService::Shutdown() {
process_ids_.clear();
+
+ if (instant_io_context_) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::ClearInstantProcessesOnIO,
+ instant_io_context_));
+ }
+ instant_io_context_ = NULL;
}
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 (instant_io_context_) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstantIOContext::RemoveInstantProcessOnIO,
+ instant_io_context_, process_id));
+ }
}
« no previous file with comments | « chrome/browser/instant/instant_service.h ('k') | chrome/browser/instant/instant_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698