| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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_SHELL_LOADER_H_ |
| 6 #define MOJO_SHELL_LOADER_H_ |
| 7 |
| 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread.h" |
| 12 #include "mojo/shell/url_request_context_getter.h" |
| 13 #include "net/url_request/url_fetcher.h" |
| 14 #include "net/url_request/url_fetcher_delegate.h" |
| 15 #include "url/gurl.h" |
| 16 |
| 17 namespace mojo { |
| 18 namespace shell { |
| 19 |
| 20 class Loader { |
| 21 public: |
| 22 class Delegate { |
| 23 public: |
| 24 virtual void DidCompleteLoad(const GURL& app_url, |
| 25 const base::FilePath& app_path) = 0; |
| 26 |
| 27 protected: |
| 28 virtual ~Delegate(); |
| 29 }; |
| 30 |
| 31 class Job : public net::URLFetcherDelegate { |
| 32 public: |
| 33 // You can cancel a job by deleting it. |
| 34 virtual ~Job(); |
| 35 |
| 36 private: |
| 37 friend class Loader; |
| 38 |
| 39 // You can create a job using Loader::Load. |
| 40 Job(const GURL& app_url, Delegate* delegate); |
| 41 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 42 |
| 43 scoped_ptr<net::URLFetcher> fetcher_; |
| 44 Delegate* delegate_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(Job); |
| 47 }; |
| 48 |
| 49 Loader(base::SingleThreadTaskRunner* network_runner, |
| 50 base::SingleThreadTaskRunner* file_runner, |
| 51 base::FilePath base_path); |
| 52 ~Loader(); |
| 53 |
| 54 scoped_ptr<Job> Load(const GURL& app_url, Delegate* delegate); |
| 55 |
| 56 private: |
| 57 scoped_refptr<base::SingleThreadTaskRunner> file_runner_; |
| 58 scoped_ptr<base::Thread> cache_thread_; |
| 59 scoped_refptr<URLRequestContextGetter> url_request_context_getter_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(Loader); |
| 62 }; |
| 63 |
| 64 } // namespace shell |
| 65 } // namespace mojo |
| 66 |
| 67 #endif // MOJO_SHELL_LOADER_H_ |
| OLD | NEW |