remote_callback_freer.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_
  5. #define ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_
  6. #include <string>
  7. #include "atom/common/api/object_life_monitor.h"
  8. #include "content/public/browser/web_contents_observer.h"
  9. namespace atom {
  10. class RemoteCallbackFreer : public ObjectLifeMonitor,
  11. public content::WebContentsObserver {
  12. public:
  13. static void BindTo(v8::Isolate* isolate,
  14. v8::Local<v8::Object> target,
  15. int frame_id,
  16. const std::string& context_id,
  17. int object_id,
  18. content::WebContents* web_conents);
  19. protected:
  20. RemoteCallbackFreer(v8::Isolate* isolate,
  21. v8::Local<v8::Object> target,
  22. int frame_id,
  23. const std::string& context_id,
  24. int object_id,
  25. content::WebContents* web_conents);
  26. ~RemoteCallbackFreer() override;
  27. void RunDestructor() override;
  28. // content::WebContentsObserver:
  29. void RenderViewDeleted(content::RenderViewHost*) override;
  30. private:
  31. int frame_id_;
  32. std::string context_id_;
  33. int object_id_;
  34. DISALLOW_COPY_AND_ASSIGN(RemoteCallbackFreer);
  35. };
  36. } // namespace atom
  37. #endif // ATOM_COMMON_API_REMOTE_CALLBACK_FREER_H_