summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_host.cc
blob: 99f0544f05e34b9d62fa77778f10152564928464 (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 (c) 2009 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 "webkit/appcache/appcache_host.h"

#include "base/logging.h"
#include "webkit/appcache/appcache.h"
#include "webkit/appcache/appcache_group.h"
#include "webkit/appcache/appcache_interfaces.h"

namespace appcache {

AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend)
  : host_id_(host_id),
    selected_cache_(NULL),
    group_(NULL),
    frontend_(frontend) {
}

AppCacheHost::~AppCacheHost() {
  if (selected_cache_)
    set_selected_cache(NULL);
  DCHECK(!group_);
}

void AppCacheHost::set_selected_cache(AppCache *cache) {
  if (selected_cache_)
    selected_cache_->UnassociateHost(this);

  selected_cache_ = cache;

  if (cache) {
    cache->AssociateHost(this);
    group_ = cache->owning_group();
  } else {
    group_ = NULL;
  }
}

}  // namespace appcache