| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Chrome::DevToolsProtocol::Transport; |
|
2
|
69
|
|
|
69
|
|
111742
|
use strict; |
|
|
69
|
|
|
|
|
184
|
|
|
|
69
|
|
|
|
|
2101
|
|
|
3
|
69
|
|
|
69
|
|
833
|
use Filter::signatures; |
|
|
69
|
|
|
|
|
26693
|
|
|
|
69
|
|
|
|
|
496
|
|
|
4
|
69
|
|
|
69
|
|
1833
|
no warnings 'experimental::signatures'; |
|
|
69
|
|
|
|
|
169
|
|
|
|
69
|
|
|
|
|
5859
|
|
|
5
|
69
|
|
|
69
|
|
1813
|
use feature 'signatures'; |
|
|
69
|
|
|
|
|
166
|
|
|
|
69
|
|
|
|
|
33212
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.69'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Chrome::DevToolsProtocol::Transport - choose the best transport backend |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @loops; |
|
16
|
|
|
|
|
|
|
push @loops, ( |
|
17
|
|
|
|
|
|
|
['Mojo/IOLoop.pm' => 'Chrome::DevToolsProtocol::Transport::Mojo' ], |
|
18
|
|
|
|
|
|
|
['IO/Async.pm' => 'Chrome::DevToolsProtocol::Transport::NetAsync'], |
|
19
|
|
|
|
|
|
|
['IO/Async/Loop.pm' => 'Chrome::DevToolsProtocol::Transport::NetAsync'], |
|
20
|
|
|
|
|
|
|
['AnyEvent.pm' => 'Chrome::DevToolsProtocol::Transport::AnyEvent'], |
|
21
|
|
|
|
|
|
|
['AE.pm' => 'Chrome::DevToolsProtocol::Transport::AnyEvent'], |
|
22
|
|
|
|
|
|
|
# native POE support would be nice |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
our $implementation; |
|
25
|
|
|
|
|
|
|
our $default = 'Chrome::DevToolsProtocol::Transport::NetAsync'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 C<< Chrome::DevToolsProtocol::Transport->new() >> |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $ua = Chrome::DevToolsProtocol::Transport->new(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Creates a new instance of the transport using the "best" event loop |
|
34
|
|
|
|
|
|
|
for implementation. The default event loop is currently L<AnyEvent>. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
All parameters are passed on to the implementation class. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
1
|
3
|
sub new($factoryclass, @args) { |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
41
|
1
|
|
33
|
|
|
7
|
$implementation ||= $factoryclass->best_implementation(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Just in case a user has set this from the outside |
|
44
|
1
|
|
|
|
|
70
|
eval "require $implementation; 1"; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# return a new instance |
|
47
|
1
|
|
|
|
|
12
|
$implementation->new(@args); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
0
|
2
|
sub best_implementation( $class, @candidates ) { |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
50
|
|
|
|
3
|
if(! @candidates) { |
|
53
|
1
|
|
|
|
|
4
|
@candidates = @loops; |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Find the currently running/loaded event loop(s) |
|
57
|
|
|
|
|
|
|
#use Data::Dumper; |
|
58
|
|
|
|
|
|
|
#warn Dumper \%INC; |
|
59
|
|
|
|
|
|
|
#warn Dumper \@candidates; |
|
60
|
|
|
|
|
|
|
my @applicable_implementations = map { |
|
61
|
0
|
|
|
|
|
0
|
$_->[1] |
|
62
|
|
|
|
|
|
|
} grep { |
|
63
|
1
|
|
|
|
|
4
|
$INC{$_->[0]} |
|
|
5
|
|
|
|
|
18
|
|
|
64
|
|
|
|
|
|
|
} @candidates; |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
50
|
|
|
|
3
|
if( ! @applicable_implementations ) { |
|
67
|
1
|
|
|
|
|
5
|
@applicable_implementations = ($default, map {$_->[1]} @candidates); |
|
|
5
|
|
|
|
|
10
|
|
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Check which one we can load: |
|
71
|
1
|
|
|
|
|
4
|
for my $impl (@applicable_implementations) { |
|
72
|
1
|
50
|
|
|
|
80
|
if( eval "require $impl; 1" ) { |
|
73
|
1
|
|
|
|
|
15
|
return $impl; |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# This will crash and burn, but that's how it is |
|
78
|
0
|
|
|
|
|
|
eval "require $default; 1"; |
|
79
|
0
|
|
|
|
|
|
return $default; |
|
80
|
|
|
|
|
|
|
}; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SUPPORTED BACKENDS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The module will try to guess the best backend to use. The currently supported |
|
87
|
|
|
|
|
|
|
backends are |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<IO::Async> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is the default backend |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<AnyEvent> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This needs the following additional modules installed: |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<AnyEvent::WebSocket::Client> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<AnyEvent::Future> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L<Mojolicious> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This needs the following additional modules installed: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<Future::Mojo> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
If you want to substitute another backend, pass its class name instead |
|
118
|
|
|
|
|
|
|
of this module which only acts as a factory. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The public repository of this module is |
|
123
|
|
|
|
|
|
|
L<https://github.com/Corion/www-mechanize-chrome>. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SUPPORT |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The public support forum of this module is L<https://perlmonks.org/>. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 BUG TRACKER |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Please report bugs in this module via the Github bug queue at |
|
132
|
|
|
|
|
|
|
L<https://github.com/Corion/WWW-Mechanize-Chrome/issues> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Max Maischein C<corion@cpan.org> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Copyright 2010-2023 by Max Maischein C<corion@cpan.org>. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 LICENSE |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |