JavaScriptChild.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  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. #ifndef mozilla_jsipc_JavaScriptChild_h_
  7. #define mozilla_jsipc_JavaScriptChild_h_
  8. #include "JavaScriptBase.h"
  9. #include "mozilla/jsipc/PJavaScriptChild.h"
  10. namespace mozilla {
  11. namespace jsipc {
  12. class JavaScriptChild : public JavaScriptBase<PJavaScriptChild>
  13. {
  14. public:
  15. JavaScriptChild() : strongReferenceObjIdMinimum_(0) {}
  16. virtual ~JavaScriptChild();
  17. bool init();
  18. void trace(JSTracer* trc);
  19. void updateWeakPointers();
  20. void drop(JSObject* obj);
  21. bool allowMessage(JSContext* cx) override { return true; }
  22. protected:
  23. virtual bool isParent() override { return false; }
  24. virtual JSObject* scopeForTargetObjects() override;
  25. bool RecvDropTemporaryStrongReferences(const uint64_t& upToObjId) override;
  26. private:
  27. bool fail(JSContext* cx, ReturnStatus* rs);
  28. bool ok(ReturnStatus* rs);
  29. // JavaScriptChild will keep strong references to JS objects that are
  30. // referenced by the parent only if their ID is >=
  31. // strongReferenceObjIdMinimum_.
  32. uint64_t strongReferenceObjIdMinimum_;
  33. };
  34. } // namespace jsipc
  35. } // namespace mozilla
  36. #endif