line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Page::PageTimings; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
880
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.19; |
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+|-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+|\-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 |
95
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
96
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
97
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
|
|
|
|
Carp::croak( |
102
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
|
return $old; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub TO_JSON { |
109
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
110
|
0
|
|
|
|
|
|
my $json = {}; |
111
|
0
|
0
|
|
|
|
|
if ( defined $self->on_content_load() ) { |
112
|
0
|
|
|
|
|
|
$json->{onContentLoad} = $self->on_content_load(); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
else { |
115
|
0
|
|
|
|
|
|
$json->{onContentLoad} = _DOES_NOT_APPLY(); |
116
|
|
|
|
|
|
|
} |
117
|
0
|
0
|
|
|
|
|
if ( defined $self->on_load() ) { |
118
|
0
|
|
|
|
|
|
$json->{onLoad} = $self->on_load(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
0
|
|
|
|
|
|
$json->{onLoad} = _DOES_NOT_APPLY(); |
122
|
|
|
|
|
|
|
} |
123
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
124
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
128
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
129
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
return $json; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
__END__ |