Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4dfef099
Commit
4dfef099
authored
Jan 28, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1442 from Hixie/shell
Clean up shell.dart
parents
1f35d451
57b68a52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
40 deletions
+36
-40
shell.dart
packages/flutter/lib/src/services/shell.dart
+35
-39
mock_services.dart
packages/flutter/test/services/mock_services.dart
+1
-1
No files found.
packages/flutter/lib/src/services/shell.dart
View file @
4dfef099
...
...
@@ -7,51 +7,55 @@ import 'dart:ui_internals' as internals;
import
'package:mojo/application.dart'
;
import
'package:mojo/bindings.dart'
as
bindings
;
import
'package:mojo/core.dart'
as
core
;
import
'package:mojo/mojo/service_provider.mojom.dart'
;
import
'package:mojo/mojo/shell.mojom.dart'
;
import
'package:mojo/mojo/service_provider.mojom.dart'
as
mojom
;
import
'package:mojo/mojo/shell.mojom.dart'
as
mojom
;
// A replacement for shell.connectToService. Implementations should return true
// if they handled the request, or false if the request should fall through
// to the default requestService.
typedef
bool
OverrideConnectToService
(
String
url
,
Object
proxy
);
// Set this to intercept calls to shell.connectToService and supply an
// alternative implementation of a service (for example, a mock for testing).
OverrideConnectToService
overrideConnectToService
;
class
MojoShell
{
MojoShell
.
_
();
ShellProxy
_initShellProxy
(
)
{
core
.
MojoHandle
shellHandle
=
new
core
.
MojoHandle
(
internals
.
takeShellProxyHandle
());
if
(!
shellHandle
.
isValid
)
return
null
;
return
new
ShellProxy
.
fromHandle
(
shellHandle
);
}
ApplicationConnection
_initEmbedderConnection
(
)
{
core
.
MojoHandle
servicesHandle
=
new
core
.
MojoHandle
(
internals
.
takeServicesProvidedByEmbedder
());
core
.
MojoHandle
exposedServicesHandle
=
new
core
.
MojoHandle
(
internals
.
takeServicesProvidedToEmbedder
());
if
(!
servicesHandle
.
isValid
||
!
exposedServicesHandle
.
isValid
)
return
null
;
ServiceProviderProxy
services
=
new
ServiceProviderProxy
.
fromHandle
(
servicesHandle
);
ServiceProviderStub
exposedServices
=
new
ServiceProviderStub
.
fromHandle
(
exposedServicesHandle
);
return
new
ApplicationConnection
(
exposedServices
,
services
);
}
final
ShellProxy
_shellProxy
=
_initShellProxy
();
final
Shell
_shell
=
_shellProxy
?.
ptr
;
final
ApplicationConnection
_embedderConnection
=
_initEmbedderConnection
();
static
mojom
.
ShellProxy
_initShellProxy
()
{
core
.
MojoHandle
shellHandle
=
new
core
.
MojoHandle
(
internals
.
takeShellProxyHandle
());
if
(!
shellHandle
.
isValid
)
return
null
;
return
new
mojom
.
ShellProxy
.
fromHandle
(
shellHandle
);
}
static
final
mojom
.
Shell
_shell
=
_initShellProxy
()?.
ptr
;
class
_Shell
{
_Shell
.
_
();
static
ApplicationConnection
_initEmbedderConnection
()
{
core
.
MojoHandle
servicesHandle
=
new
core
.
MojoHandle
(
internals
.
takeServicesProvidedByEmbedder
());
core
.
MojoHandle
exposedServicesHandle
=
new
core
.
MojoHandle
(
internals
.
takeServicesProvidedToEmbedder
());
if
(!
servicesHandle
.
isValid
||
!
exposedServicesHandle
.
isValid
)
return
null
;
mojom
.
ServiceProviderProxy
services
=
new
mojom
.
ServiceProviderProxy
.
fromHandle
(
servicesHandle
);
mojom
.
ServiceProviderStub
exposedServices
=
new
mojom
.
ServiceProviderStub
.
fromHandle
(
exposedServicesHandle
);
return
new
ApplicationConnection
(
exposedServices
,
services
);
}
static
final
ApplicationConnection
_embedderConnection
=
_initEmbedderConnection
();
ApplicationConnection
connectToApplication
(
String
url
)
{
if
(
_shell
==
null
)
return
null
;
ServiceProviderProxy
services
=
new
ServiceProviderProxy
.
unbound
();
ServiceProviderStub
exposedServices
=
new
ServiceProviderStub
.
unbound
();
mojom
.
ServiceProviderProxy
services
=
new
mojom
.
ServiceProviderProxy
.
unbound
();
mojom
.
ServiceProviderStub
exposedServices
=
new
mojom
.
ServiceProviderStub
.
unbound
();
_shell
.
connectToApplication
(
url
,
services
,
exposedServices
);
return
new
ApplicationConnection
(
exposedServices
,
services
);
}
// Set this to intercept calls to shell.connectToService and supply an
// alternative implementation of a service (for example, a mock for testing).
OverrideConnectToService
overrideConnectToService
;
void
connectToService
(
String
url
,
bindings
.
ProxyBase
proxy
)
{
if
(
overrideConnectToService
!=
null
&&
overrideConnectToService
(
url
,
proxy
))
return
;
_connectToService
(
url
,
proxy
);
}
void
_connectToService
(
String
url
,
bindings
.
ProxyBase
proxy
)
{
if
(
_shell
==
null
||
url
==
null
)
{
// If we don't have a shell or a url, we try to get the services from the
...
...
@@ -59,20 +63,12 @@ class _Shell {
_embedderConnection
?.
requestService
(
proxy
);
return
;
}
ServiceProviderProxy
services
=
new
ServiceProviderProxy
.
unbound
();
mojom
.
ServiceProviderProxy
services
=
new
mojom
.
ServiceProviderProxy
.
unbound
();
_shell
.
connectToApplication
(
url
,
services
,
null
);
core
.
MojoMessagePipe
pipe
=
new
core
.
MojoMessagePipe
();
proxy
.
impl
.
bind
(
pipe
.
endpoints
[
0
]);
services
.
ptr
.
connectToService
(
proxy
.
serviceName
,
pipe
.
endpoints
[
1
]);
services
.
close
();
}
void
connectToService
(
String
url
,
bindings
.
ProxyBase
proxy
)
{
if
(
overrideConnectToService
!=
null
&&
overrideConnectToService
(
url
,
proxy
))
return
;
_connectToService
(
url
,
proxy
);
}
}
final
_Shell
shell
=
new
_Shell
.
_
();
final
MojoShell
shell
=
new
MojoShell
.
_
();
packages/flutter/test/services/mock_services.dart
View file @
4dfef099
import
'package:flutter/src/services/shell.dart'
as
shell
;
import
'package:flutter/src/services/shell.dart'
;
import
'package:mojo/bindings.dart'
as
bindings
;
// Tests can use ServiceMocker to register replacement implementations
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment