Class: WebkitRemote::Event::NetworkMemoryCacheHit

Inherits:
WebkitRemote::Event show all
Defined in:
lib/webkit_remote/client/network_events.rb

Overview

Emitted when a resource is served from the local cache.

Instance Attribute Summary collapse

Attributes inherited from WebkitRemote::Event

#domain, #name, #raw_data

Instance Method Summary collapse

Methods inherited from WebkitRemote::Event

can_reach?, can_receive?, class_for, for, #matches?, register, register_class

Constructor Details

#initialize(rpc_event, client) ⇒ NetworkMemoryCacheHit

Returns a new instance of NetworkMemoryCacheHit.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/webkit_remote/client/network_events.rb', line 130

def initialize(rpc_event, client)
  super

  if raw_data['resource']
    @cache_data = WebkitRemote::Client::NetworkCacheEntry.new(
        raw_data['resource'])
  end
  @document_url = raw_data['documentURL']
  if raw_data['initiator']
    @initiator = WebkitRemote::Client::NetworkRequestInitiator.new(
        raw_data['initiator'])
  end
  @loader_id = raw_data['loaderId']
  @timestamp = raw_data['timestamp']

  @resource = client.network_resource raw_data['requestId']
  @resource.set_document_url @document_url
  @resource.set_initiator @initiator
  if @cache_data
    @resource.set_response @cache_data.response
    @resource.set_type @cache_data.type
  end
  @resource.add_event self
end

Instance Attribute Details

#cache_dataWebkitRemote::Client::NetworkCacheEntry (readonly)

Returns cached information used to produce the resource.

Returns:



117
118
119
# File 'lib/webkit_remote/client/network_events.rb', line 117

def cache_data
  @cache_data
end

#document_urlString (readonly)

Returns the URL of the document that caused this network request.

Returns:

  • (String)

    the URL of the document that caused this network request



120
121
122
# File 'lib/webkit_remote/client/network_events.rb', line 120

def document_url
  @document_url
end

#initiatorWebkitRemote::Client::NetworkRequestInitiator (readonly)

Returns cause for this network request.

Returns:



124
125
126
# File 'lib/webkit_remote/client/network_events.rb', line 124

def initiator
  @initiator
end

#resourceWebkitRemote::Client::NetworkResource (readonly)

Returns information about the resource fetched by this network operation.

Returns:



113
114
115
# File 'lib/webkit_remote/client/network_events.rb', line 113

def resource
  @resource
end

#timestampNumber (readonly)

Returns the event timestamp.

Returns:

  • (Number)

    the event timestamp



127
128
129
# File 'lib/webkit_remote/client/network_events.rb', line 127

def timestamp
  @timestamp
end