|
| 1 | +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
| 3 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | + |
| 7 | +#include "mozilla/dom/ReportingObserver.h" |
| 8 | +#include "mozilla/dom/ReportingBinding.h" |
| 9 | +#include "nsContentUtils.h" |
| 10 | +#include "nsGlobalWindowInner.h" |
| 11 | + |
| 12 | +namespace mozilla { |
| 13 | +namespace dom { |
| 14 | + |
| 15 | +NS_IMPL_CYCLE_COLLECTION_CLASS(ReportingObserver) |
| 16 | +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ReportingObserver) |
| 17 | + tmp->Disconnect(); |
| 18 | + NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow) |
| 19 | + NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback) |
| 20 | + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER |
| 21 | +NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
| 22 | + |
| 23 | +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ReportingObserver) |
| 24 | + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) |
| 25 | + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback) |
| 26 | +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
| 27 | +NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(ReportingObserver) |
| 28 | + |
| 29 | +NS_IMPL_CYCLE_COLLECTING_ADDREF(ReportingObserver) |
| 30 | +NS_IMPL_CYCLE_COLLECTING_RELEASE(ReportingObserver) |
| 31 | + |
| 32 | +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ReportingObserver) |
| 33 | + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
| 34 | + NS_INTERFACE_MAP_ENTRY(nsISupports) |
| 35 | +NS_INTERFACE_MAP_END |
| 36 | + |
| 37 | +/* static */ already_AddRefed<ReportingObserver> |
| 38 | +ReportingObserver::Constructor(const GlobalObject& aGlobal, |
| 39 | + ReportingObserverCallback& aCallback, |
| 40 | + const ReportingObserverOptions& aOptions, |
| 41 | + ErrorResult& aRv) |
| 42 | +{ |
| 43 | + nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); |
| 44 | + MOZ_ASSERT(window); |
| 45 | + |
| 46 | + nsTArray<nsString> types; |
| 47 | + if (aOptions.mTypes.WasPassed()) { |
| 48 | + types = aOptions.mTypes.Value(); |
| 49 | + } |
| 50 | + |
| 51 | + RefPtr<ReportingObserver> ro = |
| 52 | + new ReportingObserver(window, aCallback, types, aOptions.mBuffered); |
| 53 | + return ro.forget(); |
| 54 | +} |
| 55 | + |
| 56 | +ReportingObserver::ReportingObserver(nsPIDOMWindowInner* aWindow, |
| 57 | + ReportingObserverCallback& aCallback, |
| 58 | + const nsTArray<nsString>& aTypes, |
| 59 | + bool aBuffered) |
| 60 | + : mWindow(aWindow) |
| 61 | + , mCallback(&aCallback) |
| 62 | + , mTypes(aTypes) |
| 63 | + , mBuffered(aBuffered) |
| 64 | +{ |
| 65 | + MOZ_ASSERT(aWindow); |
| 66 | +} |
| 67 | + |
| 68 | +ReportingObserver::~ReportingObserver() |
| 69 | +{ |
| 70 | + Disconnect(); |
| 71 | +} |
| 72 | + |
| 73 | +JSObject* |
| 74 | +ReportingObserver::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
| 75 | +{ |
| 76 | + return ReportingObserver_Binding::Wrap(aCx, this, aGivenProto); |
| 77 | +} |
| 78 | + |
| 79 | +void |
| 80 | +ReportingObserver::Observe() |
| 81 | +{ |
| 82 | + // TODO |
| 83 | +} |
| 84 | + |
| 85 | +void |
| 86 | +ReportingObserver::Disconnect() |
| 87 | +{ |
| 88 | + // TODO |
| 89 | +} |
| 90 | + |
| 91 | +void |
| 92 | +ReportingObserver::TakeRecords(nsTArray<RefPtr<Report>>& aRecords) |
| 93 | +{ |
| 94 | + // TODO |
| 95 | +} |
| 96 | + |
| 97 | +} // dom namespace |
| 98 | +} // mozilla namespace |
0 commit comments