Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: utils/pub/system_cache.dart

Issue 12790006: Remove support for SDK dependencies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library system_cache; 5 library system_cache;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import '../../pkg/pathos/lib/path.dart' as path; 10 import '../../pkg/pathos/lib/path.dart' as path;
11 11
12 import 'git_source.dart'; 12 import 'git_source.dart';
13 import 'hosted_source.dart'; 13 import 'hosted_source.dart';
14 import 'io.dart'; 14 import 'io.dart';
15 import 'io.dart' as io show createTempDir; 15 import 'io.dart' as io show createTempDir;
16 import 'log.dart' as log; 16 import 'log.dart' as log;
17 import 'package.dart'; 17 import 'package.dart';
18 import 'path_source.dart'; 18 import 'path_source.dart';
19 import 'pubspec.dart'; 19 import 'pubspec.dart';
20 import 'sdk_source.dart';
21 import 'source.dart'; 20 import 'source.dart';
22 import 'source_registry.dart'; 21 import 'source_registry.dart';
23 import 'utils.dart'; 22 import 'utils.dart';
24 import 'version.dart'; 23 import 'version.dart';
25 24
26 /// The system-wide cache of installed packages. 25 /// The system-wide cache of installed packages.
27 /// 26 ///
28 /// This cache contains all packages that are downloaded from the internet. 27 /// This cache contains all packages that are downloaded from the internet.
29 /// Packages that are available locally (e.g. from the SDK) don't use this 28 /// Packages that are available locally (e.g. path dependencies) don't use this
30 /// cache. 29 /// cache.
31 class SystemCache { 30 class SystemCache {
32 /// The root directory where this package cache is located. 31 /// The root directory where this package cache is located.
33 final String rootDir; 32 final String rootDir;
34 33
35 String get tempDir => path.join(rootDir, '_temp'); 34 String get tempDir => path.join(rootDir, '_temp');
36 35
37 /// Packages which are currently being asynchronously installed to the cache. 36 /// Packages which are currently being asynchronously installed to the cache.
38 final Map<PackageId, Future<Package>> _pendingInstalls; 37 final Map<PackageId, Future<Package>> _pendingInstalls;
39 38
40 /// The sources from which to install packages. 39 /// The sources from which to install packages.
41 final SourceRegistry sources; 40 final SourceRegistry sources;
42 41
43 /// Creates a new package cache which is backed by the given directory on the 42 /// Creates a new package cache which is backed by the given directory on the
44 /// user's file system. 43 /// user's file system.
45 SystemCache(this.rootDir) 44 SystemCache(this.rootDir)
46 : _pendingInstalls = new Map<PackageId, Future<Package>>(), 45 : _pendingInstalls = new Map<PackageId, Future<Package>>(),
47 sources = new SourceRegistry(); 46 sources = new SourceRegistry();
48 47
49 /// Creates a system cache and registers the standard set of sources. 48 /// Creates a system cache and registers the standard set of sources.
50 factory SystemCache.withSources(String rootDir) { 49 factory SystemCache.withSources(String rootDir) {
51 var cache = new SystemCache(rootDir); 50 var cache = new SystemCache(rootDir);
52 cache.register(new GitSource()); 51 cache.register(new GitSource());
53 cache.register(new HostedSource()); 52 cache.register(new HostedSource());
54 cache.register(new PathSource()); 53 cache.register(new PathSource());
55 cache.register(new SdkSource());
56 cache.sources.setDefault('hosted'); 54 cache.sources.setDefault('hosted');
57 return cache; 55 return cache;
58 } 56 }
59 57
60 /// Registers a new source. This source must not have the same name as a 58 /// Registers a new source. This source must not have the same name as a
61 /// source that's already been registered. 59 /// source that's already been registered.
62 void register(Source source) { 60 void register(Source source) {
63 source.bind(this); 61 source.bind(this);
64 sources.register(source); 62 sources.register(source);
65 } 63 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 110
113 /// Delete's the system cache's internal temp directory. 111 /// Delete's the system cache's internal temp directory.
114 Future deleteTempDir() { 112 Future deleteTempDir() {
115 log.fine('Clean up system cache temp directory $tempDir.'); 113 log.fine('Clean up system cache temp directory $tempDir.');
116 return defer(() { 114 return defer(() {
117 if (!dirExists(tempDir)) return; 115 if (!dirExists(tempDir)) return;
118 return deleteDir(tempDir); 116 return deleteDir(tempDir);
119 }); 117 });
120 } 118 }
121 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698