Skip to content

Commit

Permalink
s/isOwned/closeEngine/g
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Feb 22, 2024
1 parent 3ca9f56 commit e951f15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ void testEngineClose() {

test('engine owned close', () {
final engine = CronetEngine.build();
CronetClient.fromCronetEngine(engine, isOwned: true).close();
CronetClient.fromCronetEngine(engine, closeEngine: true).close();
});

test('engine not owned close', () {
final engine = CronetEngine.build();
CronetClient.fromCronetEngine(engine, isOwned: false).close();
CronetClient.fromCronetEngine(engine, closeEngine: false).close();
engine.close();
});
});
Expand Down
2 changes: 1 addition & 1 deletion pkgs/cronet_http/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
cacheMode: CacheMode.memory,
cacheMaxSize: 2 * 1024 * 1024,
userAgent: 'Book Agent');
httpClient = CronetClient.fromCronetEngine(engine, isOwned: true);
httpClient = CronetClient.fromCronetEngine(engine, closeEngine: true);
} else {
httpClient = IOClient(HttpClient()..userAgent = 'Book Agent');
}
Expand Down
16 changes: 8 additions & 8 deletions pkgs/cronet_http/lib/src/cronet_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ class CronetClient extends BaseClient {
bool _isClosed = false;

/// Indicates that [CronetClient] is responsible for closing [_engine].
final bool _ownedEngine;
final bool _closeEngine;

CronetClient._(this._engine, this._ownedEngine) {
CronetClient._(this._engine, this._closeEngine) {
Jni.initDLApi();
}

Expand All @@ -293,12 +293,12 @@ class CronetClient extends BaseClient {

/// A [CronetClient] configured with a [CronetEngine].
///
/// If [isOwned] is `true`, then [engine] will be closed when [close] is
/// called. This can simplify lifetime management if [engine] is only used
/// in one [CronetClient].
/// If [closeEngine] is `true`, then [engine] will be closed when [close] is
/// called on this [CronetClient]. This can simplify lifetime management if
/// [engine] is only used in one [CronetClient].
factory CronetClient.fromCronetEngine(CronetEngine engine,
{bool isOwned = false}) =>
CronetClient._(engine, isOwned);
{bool closeEngine = false}) =>
CronetClient._(engine, closeEngine);

/// A [CronetClient] configured with a [Future] containing a [CronetEngine].
///
Expand All @@ -318,7 +318,7 @@ class CronetClient extends BaseClient {
/// ```
@override
void close() {
if (!_isClosed && _ownedEngine) {
if (!_isClosed && _closeEngine) {
_engine?.close();
}
_isClosed = true;
Expand Down

0 comments on commit e951f15

Please sign in to comment.