summaryrefslogtreecommitdiffstats
path: root/chrome/browser/instant/instant_service.cc
blob: a3482332656d43a5e72411bbf77e3eec970be907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/instant/instant_service.h"

#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"

InstantService::InstantService() {
  registrar_.Add(this,
                 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
                 content::NotificationService::AllSources());
}

InstantService::~InstantService() {
}

void InstantService::AddInstantProcess(int process_id) {
  process_ids_.insert(process_id);
}

bool InstantService::IsInstantProcess(int process_id) const {
  return process_ids_.count(process_id) != 0;
}

int InstantService::GetInstantProcessCount() const {
  return process_ids_.size();
}

void InstantService::Shutdown() {
  process_ids_.clear();
}

void InstantService::Observe(int type,
                             const content::NotificationSource& source,
                             const content::NotificationDetails& details) {
  int process_id = content::Source<content::RenderProcessHost>(source)->GetID();
  process_ids_.erase(process_id);
}