| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_TOOLS_PACKAGE_MANAGER_FETCHER_H_ | |
| 6 #define MOJO_TOOLS_PACKAGE_MANAGER_FETCHER_H_ | |
| 7 | |
| 8 #include "base/files/file.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "mojo/common/handle_watcher.h" | |
| 11 #include "mojo/public/cpp/system/macros.h" | |
| 12 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | |
| 13 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class FilePath; | |
| 18 } // namespace base | |
| 19 | |
| 20 namespace mojo { | |
| 21 | |
| 22 class PackageFetcherDelegate; | |
| 23 | |
| 24 class PackageFetcher { | |
| 25 public: | |
| 26 PackageFetcher(NetworkService* network_service, | |
| 27 PackageFetcherDelegate* delegate, | |
| 28 const GURL& url); | |
| 29 virtual ~PackageFetcher(); | |
| 30 | |
| 31 private: | |
| 32 void OnReceivedResponse(URLResponsePtr response); | |
| 33 | |
| 34 void ReadData(MojoResult); | |
| 35 void WaitToReadMore(); | |
| 36 | |
| 37 PackageFetcherDelegate* delegate_; | |
| 38 | |
| 39 // URL of the package. | |
| 40 GURL url_; | |
| 41 | |
| 42 URLLoaderPtr loader_; | |
| 43 | |
| 44 // Valid once file has started streaming. | |
| 45 ScopedDataPipeConsumerHandle body_; | |
| 46 common::HandleWatcher handle_watcher_; | |
| 47 | |
| 48 base::FilePath output_file_name_; | |
| 49 base::File output_file_; | |
| 50 | |
| 51 MOJO_DISALLOW_COPY_AND_ASSIGN(PackageFetcher); | |
| 52 }; | |
| 53 | |
| 54 class PackageFetcherDelegate { | |
| 55 public: | |
| 56 virtual void FetchSucceeded(const GURL& url, const base::FilePath& name) = 0; | |
| 57 | |
| 58 virtual void FetchFailed(const GURL& url) = 0; | |
| 59 }; | |
| 60 | |
| 61 } // namespace mojo | |
| 62 | |
| 63 #endif // MOJO_TOOLS_PACKAGE_MANAGER_FETCHER_H_ | |
| OLD | NEW |