line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Page::PageTimings; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
5
|
1
|
|
|
1
|
|
2
|
use Carp(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
616
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
|
|
sub _DOES_NOT_APPLY { return -1 } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
1
|
|
my ( $class, $params ) = @_; |
13
|
0
|
|
|
|
|
|
my $self = {}; |
14
|
0
|
|
|
|
|
|
bless $self, $class; |
15
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
16
|
0
|
|
|
|
|
|
$self->on_content_load( $params->{onContentLoad} ); |
17
|
0
|
|
|
|
|
|
$self->on_load( $params->{onLoad} ); |
18
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
19
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
23
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub on_content_load { |
31
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
32
|
0
|
|
|
|
|
|
my $old = $self->{onContentLoad}; |
33
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
34
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
35
|
0
|
0
|
|
|
|
|
if ( $new =~ /^(\d+(?:[.]\d+)?|-1)$/smx ) { |
36
|
0
|
|
|
|
|
|
$self->{onContentLoad} = $1 + 0; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
|
Carp::croak('on_content_load must be a positive number or -1'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
0
|
|
|
|
|
|
$self->{onContentLoad} = _DOES_NOT_APPLY(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
0
|
|
|
|
|
|
return $old; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub on_load { |
55
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
56
|
0
|
|
|
|
|
|
my $old = $self->{onLoad}; |
57
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
58
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
59
|
0
|
0
|
|
|
|
|
if ( $new =~ /^(\d+(?:[.]\d+)?|\-1)$/smx ) { |
60
|
0
|
|
|
|
|
|
$self->{onLoad} = $1 + 0; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
0
|
|
|
|
|
|
Carp::croak('on_load must be a positive number or -1'); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
|
$self->{onLoad} = _DOES_NOT_APPLY(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { |
71
|
0
|
|
|
|
|
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
return $old; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub comment { |
79
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
80
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
81
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
82
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
return $old; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub AUTOLOAD { |
88
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Page::PageTimings::AUTOLOAD; |
91
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $old; |
94
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
96
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
97
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
0
|
|
|
|
|
|
Carp::croak( |
104
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
return $old; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub TO_JSON { |
111
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
112
|
0
|
|
|
|
|
|
my $json = {}; |
113
|
0
|
0
|
|
|
|
|
if ( defined $self->on_content_load() ) { |
114
|
0
|
|
|
|
|
|
$json->{onContentLoad} = $self->on_content_load(); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
0
|
|
|
|
|
|
$json->{onContentLoad} = _DOES_NOT_APPLY(); |
118
|
|
|
|
|
|
|
} |
119
|
0
|
0
|
|
|
|
|
if ( defined $self->on_load() ) { |
120
|
0
|
|
|
|
|
|
$json->{onLoad} = $self->on_load(); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
0
|
|
|
|
|
|
$json->{onLoad} = _DOES_NOT_APPLY(); |
124
|
|
|
|
|
|
|
} |
125
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
126
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
130
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
131
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
0
|
|
|
|
|
|
return $json; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
__END__ |