Class: WebkitRemote::Client::JsObjectGroup
- Inherits:
-
Object
- Object
- WebkitRemote::Client::JsObjectGroup
- Defined in:
- lib/webkit_remote/client/runtime.rb
Overview
Tracks the remote objects in a group (think memory pool).
Instance Attribute Summary collapse
-
#client ⇒ WebkitRemote::Client
readonly
Remote debugging client for the browser tab that owns the objects in this group.
-
#name ⇒ String
readonly
The name of the group of remote objects.
-
#released ⇒ Boolean
(also: #released?)
readonly
True if the objects in this group were already released.
Instance Method Summary collapse
-
#add(object) ⇒ WebkitRemote::Client::JsObjectGroup
Registers a remote object that belongs to this group.
-
#get(remote_id) ⇒ WebkitRemote::Client::JsObject?
Returns the object in this group with a given id.
-
#include?(object) ⇒ Boolean
Checks if a remote object was allocated in this group.
-
#initialize(name, client) ⇒ JsObjectGroup
constructor
Creates a wrapper for a group of remote objects.
-
#release_all ⇒ Webkit::Client::JsObjectGroup
Releases all the remote objects in this group.
-
#remove(object) ⇒ WebkitRemote::Client::JsObjectGroup
Removes a remote object that was individually released.
Constructor Details
#initialize(name, client) ⇒ JsObjectGroup
Creates a wrapper for a group of remote objects.
392 393 394 395 396 397 398 |
# File 'lib/webkit_remote/client/runtime.rb', line 392 def initialize(name, client) @name = name @client = client # TODO(pwnall): turn @objects into a set once equality is working @objects = {} @released = false end |
Instance Attribute Details
#client ⇒ WebkitRemote::Client (readonly)
Returns remote debugging client for the browser tab that owns the objects in this group.
347 348 349 |
# File 'lib/webkit_remote/client/runtime.rb', line 347 def client @client end |
#name ⇒ String (readonly)
Returns the name of the group of remote objects.
343 344 345 |
# File 'lib/webkit_remote/client/runtime.rb', line 343 def name @name end |
#released ⇒ Boolean (readonly) Also known as: released?
Returns true if the objects in this group were already released.
350 351 352 |
# File 'lib/webkit_remote/client/runtime.rb', line 350 def released @released end |
Instance Method Details
#add(object) ⇒ WebkitRemote::Client::JsObjectGroup
Registers a remote object that belongs to this group.
408 409 410 411 412 413 414 |
# File 'lib/webkit_remote/client/runtime.rb', line 408 def add(object) if @released raise RuntimeError, 'Remote object group already released' end @objects[object.remote_id] = object self end |
#get(remote_id) ⇒ WebkitRemote::Client::JsObject?
Returns the object in this group with a given id.
This helps avoid creating multiple wrappers for the same object.
440 441 442 |
# File 'lib/webkit_remote/client/runtime.rb', line 440 def get(remote_id) @objects.fetch remote_id, nil end |
#include?(object) ⇒ Boolean
Checks if a remote object was allocated in this group.
380 381 382 |
# File 'lib/webkit_remote/client/runtime.rb', line 380 def include?(object) @objects[object.remote_id] == object end |
#release_all ⇒ Webkit::Client::JsObjectGroup
Releases all the remote objects in this group.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/webkit_remote/client/runtime.rb', line 356 def release_all return if @objects.empty? if @name == nil # This is the special group that contains un-grouped objects. @objects.values.each do |object| object.release end else @client.rpc.call 'Runtime.releaseObjectGroup', objectGroup: name end @released = true @objects.each_value { |object| object.released! } @objects.clear @client.object_group_remove self self end |
#remove(object) ⇒ WebkitRemote::Client::JsObjectGroup
Removes a remote object that was individually released.
424 425 426 427 428 429 430 431 |
# File 'lib/webkit_remote/client/runtime.rb', line 424 def remove(object) @objects.delete object.remote_id if @objects.empty? @released = true @client.object_group_remove self end self end |