Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
5e4cb2bc
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e4cb2bc
编写于
9月 20, 2016
作者:
C
Chinmay Garde
提交者:
GitHub
9月 20, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove //mojo/services/network implementations (oknet and ns_net). (#3013)
上级
c5b61691
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
0 addition
and
888 deletion
+0
-888
services/ns_net/BUILD.gn
services/ns_net/BUILD.gn
+0
-20
services/ns_net/network_service_impl.h
services/ns_net/network_service_impl.h
+0
-49
services/ns_net/network_service_impl.mm
services/ns_net/network_service_impl.mm
+0
-66
services/ns_net/url_loader_impl.h
services/ns_net/url_loader_impl.h
+0
-50
services/ns_net/url_loader_impl.mm
services/ns_net/url_loader_impl.mm
+0
-250
services/oknet/BUILD.gn
services/oknet/BUILD.gn
+0
-23
services/oknet/src/org/domokit/oknet/NetworkServiceImpl.java
services/oknet/src/org/domokit/oknet/NetworkServiceImpl.java
+0
-122
services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java
services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java
+0
-287
sky/shell/BUILD.gn
sky/shell/BUILD.gn
+0
-5
sky/shell/platform/android/io/flutter/view/FlutterMain.java
sky/shell/platform/android/io/flutter/view/FlutterMain.java
+0
-9
sky/shell/platform/mac/platform_service_provider.cc
sky/shell/platform/mac/platform_service_provider.cc
+0
-7
未找到文件。
services/ns_net/BUILD.gn
已删除
100644 → 0
浏览文件 @
c5b61691
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("ns_net") {
sources = [
"network_service_impl.h",
"network_service_impl.mm",
"url_loader_impl.h",
"url_loader_impl.mm",
]
deps = [
"//base:base",
"//mojo/data_pipe_utils",
"//mojo/public/cpp/application",
"//mojo/public/cpp/bindings:utility",
"//mojo/services/network/interfaces",
]
}
services/ns_net/network_service_impl.h
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SERVICES_NSNET_NETWORK_SERVICE_IMPL_H_
#define FLUTTER_SERVICES_NSNET_NETWORK_SERVICE_IMPL_H_
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/interfaces/network_service.mojom.h"
namespace
mojo
{
class
NetworkServiceImpl
:
public
NetworkService
{
public:
explicit
NetworkServiceImpl
(
InterfaceRequest
<
NetworkService
>
request
);
~
NetworkServiceImpl
()
override
;
void
CreateURLLoader
(
InterfaceRequest
<
URLLoader
>
loader
)
override
;
void
GetCookieStore
(
InterfaceRequest
<
CookieStore
>
cookie_store
)
override
;
void
CreateWebSocket
(
InterfaceRequest
<
WebSocket
>
socket
)
override
;
void
CreateTCPBoundSocket
(
NetAddressPtr
local_address
,
InterfaceRequest
<
TCPBoundSocket
>
bound_socket
,
const
CreateTCPBoundSocketCallback
&
callback
)
override
;
void
CreateTCPConnectedSocket
(
NetAddressPtr
remote_address
,
ScopedDataPipeConsumerHandle
send_stream
,
ScopedDataPipeProducerHandle
receive_stream
,
InterfaceRequest
<
TCPConnectedSocket
>
client_socket
,
const
CreateTCPConnectedSocketCallback
&
callback
)
override
;
void
CreateUDPSocket
(
InterfaceRequest
<
UDPSocket
>
socket
)
override
;
void
CreateHttpServer
(
NetAddressPtr
local_address
,
InterfaceHandle
<
HttpServerDelegate
>
delegate
,
const
CreateHttpServerCallback
&
callback
)
override
;
void
RegisterURLLoaderInterceptor
(
InterfaceHandle
<
URLLoaderInterceptorFactory
>
factory
)
override
;
void
CreateHostResolver
(
InterfaceRequest
<
HostResolver
>
host_resolver
)
override
;
private:
StrongBinding
<
NetworkService
>
binding_
;
DISALLOW_COPY_AND_ASSIGN
(
NetworkServiceImpl
);
};
}
// namespace mojo
#endif // FLUTTER_SERVICES_NSNET_NETWORK_SERVICE_IMPL_H_
services/ns_net/network_service_impl.mm
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/services/ns_net/network_service_impl.h"
#include "flutter/services/ns_net/url_loader_impl.h"
#include "base/logging.h"
namespace
mojo
{
NetworkServiceImpl
::
NetworkServiceImpl
(
InterfaceRequest
<
NetworkService
>
request
)
:
binding_
(
this
,
request
.
Pass
())
{}
NetworkServiceImpl
::~
NetworkServiceImpl
()
{}
void
NetworkServiceImpl
::
CreateURLLoader
(
InterfaceRequest
<
URLLoader
>
loader
)
{
new
URLLoaderImpl
(
loader
.
Pass
());
}
void
NetworkServiceImpl
::
GetCookieStore
(
InterfaceRequest
<
CookieStore
>
cookie_store
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateWebSocket
(
InterfaceRequest
<
WebSocket
>
socket
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateTCPBoundSocket
(
NetAddressPtr
local_address
,
InterfaceRequest
<
TCPBoundSocket
>
bound_socket
,
const
CreateTCPBoundSocketCallback
&
callback
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateTCPConnectedSocket
(
NetAddressPtr
remote_address
,
ScopedDataPipeConsumerHandle
send_stream
,
ScopedDataPipeProducerHandle
receive_stream
,
InterfaceRequest
<
TCPConnectedSocket
>
client_socket
,
const
CreateTCPConnectedSocketCallback
&
callback
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateUDPSocket
(
InterfaceRequest
<
UDPSocket
>
socket
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateHttpServer
(
NetAddressPtr
local_address
,
InterfaceHandle
<
HttpServerDelegate
>
delegate
,
const
CreateHttpServerCallback
&
callback
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
RegisterURLLoaderInterceptor
(
InterfaceHandle
<
URLLoaderInterceptorFactory
>
factory
)
{
DCHECK
(
false
);
}
void
NetworkServiceImpl
::
CreateHostResolver
(
InterfaceRequest
<
HostResolver
>
host_resolver
)
{
DCHECK
(
false
);
}
}
// namespace mojo
services/ns_net/url_loader_impl.h
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SERVICES_NSNET_URLLOADER_IMPL_H_
#define FLUTTER_SERVICES_NSNET_URLLOADER_IMPL_H_
#include <memory>
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/network/interfaces/url_loader.mojom.h"
@
class
NSData
,
NSURLConnection
,
URLLoaderConnectionDelegate
;
namespace
mojo
{
class
AsyncNSDataDrainer
;
class
URLLoaderImpl
:
public
URLLoader
{
public:
explicit
URLLoaderImpl
(
InterfaceRequest
<
URLLoader
>
request
);
~
URLLoaderImpl
()
override
;
void
Start
(
URLRequestPtr
request
,
const
StartCallback
&
callback
)
override
;
void
FollowRedirect
(
const
FollowRedirectCallback
&
callback
)
override
;
void
QueryStatus
(
const
QueryStatusCallback
&
callback
)
override
;
private:
StrongBinding
<
URLLoader
>
binding_
;
base
::
scoped_nsobject
<
URLLoaderConnectionDelegate
>
connection_delegate_
;
base
::
scoped_nsobject
<
NSURLConnection
>
pending_connection_
;
std
::
unique_ptr
<
AsyncNSDataDrainer
>
request_data_drainer_
;
base
::
WeakPtrFactory
<
URLLoaderImpl
>
weak_factory_
;
void
StartNow
(
URLRequestPtr
request
,
const
StartCallback
&
callback
,
NSData
*
body_data
);
DISALLOW_COPY_AND_ASSIGN
(
URLLoaderImpl
);
};
}
// namespace mojo
#endif // FLUTTER_SERVICES_NSNET_URLLOADER_IMPL_H_
services/ns_net/url_loader_impl.mm
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "url_loader_impl.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "mojo/data_pipe_utils/data_pipe_drainer.h"
#import <Foundation/Foundation.h>
static
mojo
::
URLResponsePtr
MojoErrorResponse
(
NSURL
*
url
,
NSString
*
message
)
{
mojo
::
URLResponsePtr
response
=
mojo
::
URLResponse
::
New
();
response
->
url
=
url
.
absoluteString
.
UTF8String
;
response
->
error
=
mojo
::
NetworkError
::
New
();
response
->
error
->
description
=
message
.
UTF8String
;
return
response
;
}
static
mojo
::
URLResponsePtr
MojoNetworkResponse
(
NSURL
*
url
,
NSHTTPURLResponse
*
response
,
mojo
::
ScopedDataPipeConsumerHandle
response_data
)
{
mojo
::
URLResponsePtr
mojo_response
=
mojo
::
URLResponse
::
New
();
mojo_response
->
status_code
=
static_cast
<
uint32_t
>
(
response
.
statusCode
);
mojo_response
->
url
=
url
.
absoluteString
.
UTF8String
;
NSDictionary
*
headers
=
response
.
allHeaderFields
;
if
(
headers
.
count
>
0
)
{
mojo_response
->
headers
=
mojo
::
Array
<
mojo
::
HttpHeaderPtr
>::
New
(
0
);
for
(
NSString
*
key
in
headers
.
allKeys
)
{
auto
mojo_header
=
mojo
::
HttpHeader
::
New
();
mojo_header
->
name
=
key
.
UTF8String
;
mojo_header
->
value
=
[
headers
[
key
]
UTF8String
];
mojo_response
->
headers
.
push_back
(
mojo_header
.
Pass
());
}
}
mojo_response
->
body
=
response_data
.
Pass
();
return
mojo_response
;
}
@interface
URLLoaderConnectionDelegate
:
NSObject
<
NSURLConnectionDataDelegate
>
@end
@implementation
URLLoaderConnectionDelegate
{
mojo
::
DataPipe
_pipe
;
mojo
::
URLLoader
::
StartCallback
_startCallback
;
}
-
(
instancetype
)
initWithStartCallback
:
(
mojo
::
URLLoader
::
StartCallback
)
startCallback
{
self
=
[
super
init
];
if
(
self
)
{
_startCallback
=
startCallback
;
}
return
self
;
}
-
(
void
)
invokeStartCallback
:(
mojo
::
URLResponsePtr
)
response
{
if
(
!
_startCallback
.
is_null
())
{
_startCallback
.
Run
(
response
.
Pass
());
_startCallback
.
reset
();
}
}
-
(
void
)
connection
:(
NSURLConnection
*
)
connection
didReceiveResponse
:(
NSHTTPURLResponse
*
)
response
{
auto
mojo_response
=
MojoNetworkResponse
(
connection
.
originalRequest
.
URL
,
response
,
_pipe
.
consumer_handle
.
Pass
());
[
self
invokeStartCallback
:
mojo_response
.
Pass
()];
}
-
(
void
)
connection
:(
NSURLConnection
*
)
connection
didReceiveData
:(
NSData
*
)
data
{
uint32_t
length
=
data
.
length
;
// TODO(eseidel): This can't work. The data pipe could be full, we need to
// write an async writter for filling the pipe and use it here.
MojoResult
result
=
WriteDataRaw
(
_pipe
.
producer_handle
.
get
(),
data
.
bytes
,
&
length
,
MOJO_WRITE_DATA_FLAG_ALL_OR_NONE
);
// FIXME(csg): Handle buffers in case of failures
DCHECK
(
result
==
MOJO_RESULT_OK
);
DCHECK
(
length
==
data
.
length
);
}
-
(
void
)
connectionDidFinishLoading
:(
NSURLConnection
*
)
connection
{
_pipe
.
producer_handle
.
reset
();
}
-
(
void
)
connection
:(
NSURLConnection
*
)
connection
didFailWithError
:(
NSError
*
)
error
{
// We are not going to be sending any more data.
_pipe
.
producer_handle
.
reset
();
auto
mojo_error_response
=
MojoErrorResponse
(
connection
.
originalRequest
.
URL
,
error
.
localizedDescription
);
[
self
invokeStartCallback
:
mojo_error_response
.
Pass
()];
}
-
(
NSCachedURLResponse
*
)
connection
:(
NSURLConnection
*
)
connection
willCacheResponse
:(
NSCachedURLResponse
*
)
cachedResponse
{
return
nil
;
}
-
(
void
)
dealloc
{
if
(
!
_startCallback
.
is_null
())
{
mojo
::
URLResponsePtr
cancelled
=
mojo
::
URLResponse
::
New
();
cancelled
->
error
=
mojo
::
NetworkError
::
New
();
cancelled
->
error
->
description
=
"Cancelled"
;
_startCallback
.
Run
(
cancelled
.
Pass
());
}
[
super
dealloc
];
}
@end
namespace
mojo
{
class
AsyncNSDataDrainer
:
common
::
DataPipeDrainer
::
Client
{
public:
using
CompletionCallback
=
base
::
Callback
<
void
(
NSData
*
/* transfer-none */
)
>
;
AsyncNSDataDrainer
()
:
data_
([[
NSMutableData
alloc
]
init
]),
draining_
(
false
)
{}
void
StartWithCompletionCallback
(
ScopedDataPipeConsumerHandle
source
,
CompletionCallback
callback
)
{
DCHECK
(
!
draining_
)
<<
"A instance of an AsyncNSDataDrainer can only be used to drain once"
;
DCHECK
(
drainer_
==
nullptr
);
draining_
=
true
;
callback_
=
callback
;
// There is no "Start" method on a data pipe drainer. Instantiating
// an instance automatically starts the drain.
drainer_
=
std
::
unique_ptr
<
common
::
DataPipeDrainer
>
(
new
common
::
DataPipeDrainer
(
this
,
source
.
Pass
()));
}
~
AsyncNSDataDrainer
()
override
{
[
data_
release
];
}
private:
CompletionCallback
callback_
;
NSMutableData
*
data_
;
std
::
unique_ptr
<
common
::
DataPipeDrainer
>
drainer_
;
bool
draining_
;
void
OnDataAvailable
(
const
void
*
data
,
size_t
num_bytes
)
override
{
[
data_
appendBytes
:
data
length
:
num_bytes
];
}
void
OnDataComplete
()
override
{
auto
callback
=
callback_
;
NSMutableData
*
data
=
data_
;
[
data
retain
];
// The owner of this NSData drainer may cause its collection in the callback
// If this is the first thing that happens in the callback, the final
// data_ reference may be released (in dtor) before the callback accesses
// that data further along in the same callback. So make sure we keep an
// extra reference for the duration of the callback.
callback
.
Run
(
data
);
[
data
release
];
}
DISALLOW_COPY_AND_ASSIGN
(
AsyncNSDataDrainer
);
};
URLLoaderImpl
::
URLLoaderImpl
(
InterfaceRequest
<
URLLoader
>
request
)
:
binding_
(
this
,
request
.
Pass
()),
weak_factory_
(
this
)
{}
URLLoaderImpl
::~
URLLoaderImpl
()
{
[
pending_connection_
.
get
()
cancel
];
[
pending_connection_
.
get
()
unscheduleFromRunLoop
:[
NSRunLoop
mainRunLoop
]
forMode:
NSRunLoopCommonModes
];
}
void
URLLoaderImpl
::
Start
(
URLRequestPtr
request
,
const
StartCallback
&
callback
)
{
if
(
request
->
body
.
size
()
==
1
)
{
// If the body has request data, try to drain that
request_data_drainer_
=
std
::
unique_ptr
<
AsyncNSDataDrainer
>
(
new
AsyncNSDataDrainer
());
request_data_drainer_
->
StartWithCompletionCallback
(
request
->
body
[
0
].
Pass
(),
// handle
base
::
Bind
(
&
URLLoaderImpl
::
StartNow
,
weak_factory_
.
GetWeakPtr
(),
base
::
Passed
(
&
request
),
callback
));
}
else
{
StartNow
(
request
.
Pass
(),
callback
,
nullptr
);
}
}
void
URLLoaderImpl
::
StartNow
(
URLRequestPtr
request
,
const
StartCallback
&
callback
,
NSData
*
body_data
)
{
base
::
mac
::
ScopedNSAutoreleasePool
pool
;
request_data_drainer_
.
reset
();
// Create the URL Request.
NSURL
*
url
=
[
NSURL
URLWithString
:
@
(
request
->
url
.
data
())];
NSMutableURLRequest
*
url_request
=
[
NSMutableURLRequest
requestWithURL
:
url
];
url_request
.
HTTPMethod
=
@
(
request
->
method
.
data
());
url_request
.
HTTPBody
=
body_data
;
// by copy
for
(
const
auto
&
header
:
request
->
headers
)
{
[
url_request
addValue
:
@
(
header
->
value
.
data
())
forHTTPHeaderField:
@
(
header
->
name
.
data
())];
};
// Create the connection and its delegate.
connection_delegate_
.
reset
(
[[
URLLoaderConnectionDelegate
alloc
]
initWithStartCallback
:
callback
]);
pending_connection_
.
reset
([[
NSURLConnection
alloc
]
initWithRequest:
url_request
delegate:
connection_delegate_
startImmediately:
NO
]);
// Schedule the connection on the main run loop.
[
pending_connection_
scheduleInRunLoop
:[
NSRunLoop
mainRunLoop
]
forMode:
NSRunLoopCommonModes
];
// Start the connection.
[
pending_connection_
start
];
}
void
URLLoaderImpl
::
FollowRedirect
(
const
FollowRedirectCallback
&
callback
)
{
DCHECK
(
false
);
}
void
URLLoaderImpl
::
QueryStatus
(
const
QueryStatusCallback
&
callback
)
{
DCHECK
(
false
);
}
}
// namespace mojo
services/oknet/BUILD.gn
已删除
100644 → 0
浏览文件 @
c5b61691
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
android_library("oknet") {
java_files = [
"src/org/domokit/oknet/NetworkServiceImpl.java",
"src/org/domokit/oknet/UrlLoaderImpl.java",
]
deps = [
"//base:base_java",
"//mojo/public/interfaces/network:network_java",
"//mojo/public/java:bindings",
"//mojo/public/java:system",
"//mojo/services/network/interfaces:interfaces_java",
"//third_party/okhttp",
"//third_party/okhttp:okio",
]
}
services/oknet/src/org/domokit/oknet/NetworkServiceImpl.java
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package
org.domokit.oknet
;
import
android.content.Context
;
import
android.util.Log
;
import
com.squareup.okhttp.Cache
;
import
com.squareup.okhttp.OkHttpClient
;
import
org.chromium.mojo.bindings.InterfaceRequest
;
import
org.chromium.mojo.system.Core
;
import
org.chromium.mojo.system.DataPipe
;
import
org.chromium.mojo.system.MojoException
;
import
org.chromium.mojom.mojo.CookieStore
;
import
org.chromium.mojom.mojo.HostResolver
;
import
org.chromium.mojom.mojo.HttpServerDelegate
;
import
org.chromium.mojom.mojo.NetAddress
;
import
org.chromium.mojom.mojo.NetworkService
;
import
org.chromium.mojom.mojo.TcpBoundSocket
;
import
org.chromium.mojom.mojo.TcpConnectedSocket
;
import
org.chromium.mojom.mojo.UdpSocket
;
import
org.chromium.mojom.mojo.UrlLoader
;
import
org.chromium.mojom.mojo.UrlLoaderInterceptorFactory
;
import
org.chromium.mojom.mojo.WebSocket
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* OkHttp implementation of NetworkService.
*/
public
class
NetworkServiceImpl
implements
NetworkService
{
private
static
final
String
TAG
=
"NetworkServiceImpl"
;
private
static
ExecutorService
sThreadPool
;
private
static
OkHttpClient
sClient
;
private
Core
mCore
;
public
NetworkServiceImpl
(
Context
context
,
Core
core
)
{
assert
core
!=
null
;
mCore
=
core
;
if
(
sThreadPool
==
null
)
{
sThreadPool
=
Executors
.
newCachedThreadPool
();
}
if
(
sClient
==
null
)
{
sClient
=
new
OkHttpClient
();
try
{
int
cacheSize
=
10
*
1024
*
1024
;
// 10 MiB
File
cacheDirectory
=
new
File
(
context
.
getCacheDir
(),
"ok_http_cache"
);
Cache
cache
=
new
Cache
(
cacheDirectory
,
cacheSize
);
sClient
.
setCache
(
cache
);
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"Unable to create HTTP cache"
,
e
);
}
}
}
@Override
public
void
close
()
{}
@Override
public
void
onConnectionError
(
MojoException
e
)
{}
@Override
public
void
createUrlLoader
(
InterfaceRequest
<
UrlLoader
>
loader
)
{
UrlLoader
.
MANAGER
.
bind
(
new
UrlLoaderImpl
(
mCore
,
sClient
,
sThreadPool
),
loader
);
}
@Override
public
void
getCookieStore
(
InterfaceRequest
<
CookieStore
>
cookieStore
)
{
cookieStore
.
close
();
}
@Override
public
void
createWebSocket
(
InterfaceRequest
<
WebSocket
>
socket
)
{
socket
.
close
();
}
@Override
public
void
createTcpBoundSocket
(
NetAddress
localAddress
,
InterfaceRequest
<
TcpBoundSocket
>
boundSocket
,
CreateTcpBoundSocketResponse
callback
)
{
boundSocket
.
close
();
}
@Override
public
void
createTcpConnectedSocket
(
NetAddress
remoteAddress
,
DataPipe
.
ConsumerHandle
sendStream
,
DataPipe
.
ProducerHandle
receiveStream
,
InterfaceRequest
<
TcpConnectedSocket
>
clientSocket
,
CreateTcpConnectedSocketResponse
callback
)
{
sendStream
.
close
();
receiveStream
.
close
();
clientSocket
.
close
();
}
@Override
public
void
createUdpSocket
(
InterfaceRequest
<
UdpSocket
>
socket
)
{
socket
.
close
();
}
@Override
public
void
createHttpServer
(
NetAddress
localAddress
,
HttpServerDelegate
delegate
,
CreateHttpServerResponse
callback
)
{
delegate
.
close
();
}
@Override
public
void
registerUrlLoaderInterceptor
(
UrlLoaderInterceptorFactory
factory
)
{
factory
.
close
();
}
@Override
public
void
createHostResolver
(
InterfaceRequest
<
HostResolver
>
resolver
)
{
resolver
.
close
();
}
}
services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java
已删除
100644 → 0
浏览文件 @
c5b61691
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package
org.domokit.oknet
;
import
android.util.Log
;
import
com.squareup.okhttp.Call
;
import
com.squareup.okhttp.Callback
;
import
com.squareup.okhttp.Headers
;
import
com.squareup.okhttp.MediaType
;
import
com.squareup.okhttp.OkHttpClient
;
import
com.squareup.okhttp.Request
;
import
com.squareup.okhttp.RequestBody
;
import
com.squareup.okhttp.Response
;
import
com.squareup.okhttp.ResponseBody
;
import
org.chromium.base.TraceEvent
;
import
org.chromium.mojo.system.Core
;
import
org.chromium.mojo.system.DataPipe
;
import
org.chromium.mojo.system.MojoException
;
import
org.chromium.mojo.system.MojoResult
;
import
org.chromium.mojo.system.Pair
;
import
org.chromium.mojom.mojo.HttpHeader
;
import
org.chromium.mojom.mojo.NetworkError
;
import
org.chromium.mojom.mojo.UrlLoader
;
import
org.chromium.mojom.mojo.UrlLoaderStatus
;
import
org.chromium.mojom.mojo.UrlRequest
;
import
org.chromium.mojom.mojo.UrlResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.Channels
;
import
java.nio.channels.WritableByteChannel
;
import
java.nio.charset.Charset
;
import
java.nio.charset.UnsupportedCharsetException
;
import
java.util.concurrent.Executor
;
import
okio.BufferedSource
;
/**
* OkHttp implementation of UrlLoader.
*/
public
class
UrlLoaderImpl
implements
UrlLoader
{
private
static
final
String
TAG
=
"UrlLoaderImpl"
;
private
final
Core
mCore
;
private
final
OkHttpClient
mClient
;
private
final
Executor
mExecutor
;
private
boolean
mIsLoading
;
private
NetworkError
mError
;
private
static
long
sNextTracingId
=
1
;
private
final
long
mTracingId
;
class
CopyToPipeJob
implements
Runnable
{
private
ResponseBody
mBody
;
private
BufferedSource
mSource
;
private
DataPipe
.
ProducerHandle
mProducer
;
public
CopyToPipeJob
(
ResponseBody
body
,
DataPipe
.
ProducerHandle
producerHandle
)
{
mBody
=
body
;
mSource
=
body
.
source
();
mProducer
=
producerHandle
;
}
@Override
public
void
run
()
{
TraceEvent
.
begin
(
"UrlLoaderImpl::CopyToPipeJob::copy"
);
int
result
=
0
;
do
{
try
{
ByteBuffer
buffer
=
mProducer
.
beginWriteData
(
0
,
DataPipe
.
WriteFlags
.
none
());
// TODO(abarth): There must be a way to do this without the temporary buffer.
byte
[]
tmp
=
new
byte
[
buffer
.
capacity
()];
result
=
mSource
.
read
(
tmp
);
buffer
.
put
(
tmp
);
mProducer
.
endWriteData
(
result
==
-
1
?
0
:
result
);
}
catch
(
MojoException
e
)
{
// No one read the pipe, they just closed it.
if
(
e
.
getMojoResult
()
==
MojoResult
.
FAILED_PRECONDITION
)
{
break
;
}
else
if
(
e
.
getMojoResult
()
==
MojoResult
.
SHOULD_WAIT
)
{
mCore
.
wait
(
mProducer
,
Core
.
HandleSignals
.
WRITABLE
,
-
1
);
}
else
{
throw
e
;
}
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"mSource.read failed"
,
e
);
break
;
}
}
while
(
result
!=
-
1
);
mIsLoading
=
false
;
mProducer
.
close
();
try
{
mBody
.
close
();
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"mBody.close failed"
,
e
);
}
TraceEvent
.
finishAsync
(
"UrlLoaderImpl"
,
mTracingId
);
TraceEvent
.
end
(
"UrlLoaderImpl::CopyToPipeJob::copy"
);
}
}
public
UrlLoaderImpl
(
Core
core
,
OkHttpClient
client
,
Executor
executor
)
{
assert
core
!=
null
;
mCore
=
core
;
mClient
=
client
;
mExecutor
=
executor
;
mIsLoading
=
false
;
mError
=
null
;
mTracingId
=
sNextTracingId
++;
}
@Override
public
void
close
()
{}
@Override
public
void
onConnectionError
(
MojoException
e
)
{}
@Override
public
void
start
(
UrlRequest
request
,
StartResponse
callback
)
{
mExecutor
.
execute
(
new
StartRequestJob
(
request
,
callback
));
}
class
StartRequestJob
implements
Runnable
{
private
final
UrlRequest
mRequest
;
private
final
StartResponse
mCallback
;
public
StartRequestJob
(
UrlRequest
request
,
StartResponse
callback
)
{
mRequest
=
request
;
mCallback
=
callback
;
}
@Override
public
void
run
()
{
TraceEvent
.
startAsync
(
"UrlLoaderImpl"
,
mTracingId
);
mIsLoading
=
true
;
mError
=
null
;
URL
url
=
null
;
try
{
url
=
new
URL
(
mRequest
.
url
);
}
catch
(
MalformedURLException
e
)
{
Log
.
w
(
TAG
,
"Failed to parse url "
+
mRequest
.
url
);
mError
=
new
NetworkError
();
// TODO(abarth): Which mError.code should we set?
mError
.
description
=
e
.
toString
();
UrlResponse
urlResponse
=
new
UrlResponse
();
urlResponse
.
url
=
mRequest
.
url
;
urlResponse
.
error
=
mError
;
mCallback
.
call
(
urlResponse
);
return
;
}
Request
.
Builder
builder
=
new
Request
.
Builder
().
url
(
url
);
String
contentType
=
null
;
if
(
mRequest
.
headers
!=
null
)
{
for
(
HttpHeader
header
:
mRequest
.
headers
)
{
if
(
header
.
name
.
toLowerCase
().
equals
(
"content-type"
))
contentType
=
header
.
value
;
builder
.
addHeader
(
header
.
name
,
header
.
value
);
}
}
RequestBody
body
=
null
;
if
(
mRequest
.
body
!=
null
&&
mRequest
.
body
[
0
]
!=
null
)
{
if
(
mRequest
.
body
.
length
>
1
)
{
Log
.
w
(
TAG
,
"POST requests with multiple bodies are not supported"
);
}
DataPipe
.
ConsumerHandle
consumer
=
mRequest
.
body
[
0
];
ByteArrayOutputStream
bodyStream
=
new
ByteArrayOutputStream
();
WritableByteChannel
dest
=
Channels
.
newChannel
(
bodyStream
);
do
{
try
{
ByteBuffer
buffer
=
consumer
.
beginReadData
(
0
,
DataPipe
.
ReadFlags
.
NONE
);
if
(
buffer
.
capacity
()
==
0
)
break
;
dest
.
write
(
buffer
);
consumer
.
endReadData
(
buffer
.
capacity
());
}
catch
(
IOException
e
)
{
throw
new
MojoException
(
e
);
}
catch
(
MojoException
e
)
{
// No one read the pipe, they just closed it.
if
(
e
.
getMojoResult
()
==
MojoResult
.
FAILED_PRECONDITION
)
{
break
;
}
else
if
(
e
.
getMojoResult
()
==
MojoResult
.
SHOULD_WAIT
)
{
mCore
.
wait
(
consumer
,
Core
.
HandleSignals
.
READABLE
,
-
1
);
}
else
{
throw
e
;
}
}
}
while
(
true
);
if
(
contentType
==
null
)
contentType
=
"application/x-www-form-urlencoded; charset=utf8"
;
MediaType
mediaType
=
MediaType
.
parse
(
contentType
);
body
=
RequestBody
.
create
(
mediaType
,
bodyStream
.
toByteArray
());
}
builder
.
method
(
mRequest
.
method
,
body
);
// TODO(abarth): responseBodyBufferSize, autoFollowRedirects, bypassCache.
Call
call
=
mClient
.
newCall
(
builder
.
build
());
call
.
enqueue
(
new
Callback
()
{
@Override
public
void
onFailure
(
Request
request
,
IOException
e
)
{
Log
.
w
(
TAG
,
"Network failure loading "
+
mRequest
.
url
);
mError
=
new
NetworkError
();
// TODO(abarth): Which mError.code should we set?
mError
.
description
=
e
.
toString
();
UrlResponse
urlResponse
=
new
UrlResponse
();
urlResponse
.
url
=
mRequest
.
url
;
urlResponse
.
error
=
mError
;
mCallback
.
call
(
urlResponse
);
mIsLoading
=
false
;
TraceEvent
.
finishAsync
(
"UrlLoaderImpl"
,
mTracingId
);
}
@Override
public
void
onResponse
(
Response
response
)
{
UrlResponse
urlResponse
=
new
UrlResponse
();
urlResponse
.
url
=
response
.
request
().
urlString
();
urlResponse
.
statusCode
=
response
.
code
();
urlResponse
.
statusLine
=
response
.
message
();
if
(
urlResponse
.
statusCode
>=
400
)
{
Log
.
w
(
TAG
,
"Failed to load: "
+
urlResponse
.
url
+
" ("
+
urlResponse
.
statusCode
+
")"
);
}
Headers
headers
=
response
.
headers
();
urlResponse
.
headers
=
new
HttpHeader
[
headers
.
size
()];
for
(
int
i
=
0
;
i
<
headers
.
size
();
++
i
)
{
HttpHeader
header
=
new
HttpHeader
();
header
.
name
=
headers
.
name
(
i
);
header
.
value
=
headers
.
value
(
i
);
urlResponse
.
headers
[
i
]
=
header
;
}
ResponseBody
body
=
response
.
body
();
MediaType
mediaType
=
body
.
contentType
();
if
(
mediaType
!=
null
)
{
urlResponse
.
mimeType
=
mediaType
.
type
()
+
"/"
+
mediaType
.
subtype
();
try
{
Charset
charset
=
mediaType
.
charset
();
if
(
charset
!=
null
)
{
urlResponse
.
charset
=
charset
.
displayName
();
}
}
catch
(
UnsupportedCharsetException
e
)
{
Log
.
e
(
TAG
,
"Unsupported charset"
,
e
);
}
}
Pair
<
DataPipe
.
ProducerHandle
,
DataPipe
.
ConsumerHandle
>
handles
=
mCore
.
createDataPipe
(
null
);
DataPipe
.
ProducerHandle
producerHandle
=
handles
.
first
;
DataPipe
.
ConsumerHandle
consumerHandle
=
handles
.
second
;
urlResponse
.
body
=
consumerHandle
;
mCallback
.
call
(
urlResponse
);
mExecutor
.
execute
(
new
CopyToPipeJob
(
body
,
producerHandle
));
}
});
}
}
@Override
public
void
followRedirect
(
FollowRedirectResponse
callback
)
{
// TODO(abarth): Implement redirects.
callback
.
call
(
new
UrlResponse
());
}
@Override
public
void
queryStatus
(
QueryStatusResponse
callback
)
{
UrlLoaderStatus
status
=
new
UrlLoaderStatus
();
status
.
error
=
mError
;
status
.
isLoading
=
mIsLoading
;
callback
.
call
(
status
);
}
}
sky/shell/BUILD.gn
浏览文件 @
5e4cb2bc
...
...
@@ -75,7 +75,6 @@ source_set("common") {
"//mojo/public/interfaces/application",
"//mojo/services/asset_bundle/interfaces",
"//mojo/services/gfx/composition/interfaces",
"//mojo/services/navigation/interfaces",
"//mojo/services/vsync/interfaces",
":generate_sky_embedder_diagnostic_server_resources_cc",
]
...
...
@@ -172,7 +171,6 @@ if (is_android) {
"//mojo/public/interfaces/application:application_java",
"//mojo/public/java:bindings",
"//mojo/public/java:system",
"//mojo/services/network/interfaces:interfaces_java",
"//mojo/services/sensors/interfaces:interfaces_java",
"//mojo/services/vsync/interfaces:interfaces_java",
"//flutter/services/sensors:sensors_lib",
...
...
@@ -184,7 +182,6 @@ if (is_android) {
"//flutter/services/engine:interfaces_java",
"//flutter/services/media:interfaces_java",
"//flutter/services/media:media_lib",
"//flutter/services/oknet",
"//flutter/services/platform:interfaces_java",
"//flutter/services/platform:platform_lib",
"//flutter/services/pointer:interfaces_java",
...
...
@@ -278,7 +275,6 @@ if (is_android) {
"//flutter/services/dynamic:embedder",
"//flutter/services/editing",
"//flutter/services/media",
"//flutter/services/ns_net",
"//flutter/services/semantics",
"//flutter/services/vsync",
":common",
...
...
@@ -443,7 +439,6 @@ if (is_android) {
"//mojo/common",
"//mojo/edk/base_edk",
"//mojo/edk/system",
"//flutter/services/ns_net",
"//flutter/services/vsync",
":common",
":gpu_direct",
...
...
sky/shell/platform/android/io/flutter/view/FlutterMain.java
浏览文件 @
5e4cb2bc
...
...
@@ -43,13 +43,11 @@ import org.chromium.mojom.flutter.platform.SystemChrome;
import
org.chromium.mojom.flutter.platform.SystemSound
;
import
org.chromium.mojom.flutter.platform.UrlLauncher
;
import
org.chromium.mojom.media.MediaService
;
import
org.chromium.mojom.mojo.NetworkService
;
import
org.chromium.mojom.sensors.SensorService
;
import
org.chromium.mojom.vsync.VSyncProvider
;
import
org.domokit.activity.ActivityImpl
;
import
org.domokit.editing.ClipboardImpl
;
import
org.domokit.media.MediaServiceImpl
;
import
org.domokit.oknet.NetworkServiceImpl
;
import
org.domokit.platform.HapticFeedbackImpl
;
import
org.domokit.platform.PathProviderImpl
;
import
org.domokit.platform.SystemChromeImpl
;
...
...
@@ -224,13 +222,6 @@ public class FlutterMain {
}
});
registry
.
register
(
NetworkService
.
MANAGER
.
getName
(),
new
ServiceFactory
()
{
@Override
public
Binding
connectToService
(
FlutterView
view
,
Core
core
,
MessagePipeHandle
pipe
)
{
return
NetworkService
.
MANAGER
.
bind
(
new
NetworkServiceImpl
(
view
.
getContext
(),
core
),
pipe
);
}
});
registry
.
register
(
SensorService
.
MANAGER
.
getName
(),
new
ServiceFactory
()
{
@Override
public
Binding
connectToService
(
FlutterView
view
,
Core
core
,
MessagePipeHandle
pipe
)
{
...
...
sky/shell/platform/mac/platform_service_provider.cc
浏览文件 @
5e4cb2bc
...
...
@@ -19,8 +19,6 @@
#include "flutter/services/vsync/mac/vsync_provider_mac_impl.h"
#endif // TARGET_OS_IPHONE
#include "flutter/services/ns_net/network_service_impl.h"
namespace
sky
{
namespace
shell
{
...
...
@@ -34,11 +32,6 @@ PlatformServiceProvider::~PlatformServiceProvider() {}
void
PlatformServiceProvider
::
ConnectToService
(
const
mojo
::
String
&
service_name
,
mojo
::
ScopedMessagePipeHandle
client_handle
)
{
if
(
service_name
==
mojo
::
NetworkService
::
Name_
)
{
new
mojo
::
NetworkServiceImpl
(
mojo
::
InterfaceRequest
<
mojo
::
NetworkService
>
(
client_handle
.
Pass
()));
return
;
}
#if TARGET_OS_IPHONE
if
(
service_name
==
::
media
::
MediaPlayer
::
Name_
)
{
new
sky
::
services
::
media
::
MediaPlayerImpl
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录