summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_resource.cc
blob: cf7a7feb243c4a7afef231a418bbdf72bb3c24ca (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
// Copyright (c) 2010 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/glue/plugins/pepper_resource.h"

#include "base/logging.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"

namespace pepper {

Resource::Resource(PluginModule* module)
    : resource_id_(0), module_(module) {
}

Resource::~Resource() {
}

PP_Resource Resource::GetReference() {
  ResourceTracker *tracker = ResourceTracker::Get();
  if (resource_id_)
    tracker->AddRefResource(resource_id_);
  else
    resource_id_ = tracker->AddResource(this);
  return resource_id_;
}

void Resource::StoppedTracking() {
  DCHECK(resource_id_ != 0);
  resource_id_ = 0;
}

}  // namespace pepper