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

Side by Side Diff: mojo/fetcher/network_fetcher.h

Issue 1563413002: Move fetchers into mojo/shell/fetcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « mojo/fetcher/local_fetcher.cc ('k') | mojo/fetcher/network_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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_FETCHER_NETWORK_FETCHER_H_
6 #define MOJO_FETCHER_NETWORK_FETCHER_H_
7
8 #include "mojo/shell/fetcher.h"
9
10 #include <stdint.h>
11
12 #include "base/files/file_path.h"
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
16 #include "url/gurl.h"
17
18 namespace mojo {
19
20 class URLLoaderFactory;
21
22 namespace fetcher {
23
24 // Implements Fetcher for http[s] files.
25 class NetworkFetcher : public shell::Fetcher {
26 public:
27 NetworkFetcher(bool disable_cache,
28 mojo::URLRequestPtr request,
29 URLLoaderFactory* url_loader_factory,
30 const FetchCallback& loader_callback);
31
32 ~NetworkFetcher() override;
33
34 private:
35 // TODO(hansmuller): Revisit this when a real peek operation is available.
36 static const MojoDeadline kPeekTimeout = MOJO_DEADLINE_INDEFINITE;
37
38 const GURL& GetURL() const override;
39 GURL GetRedirectURL() const override;
40 GURL GetRedirectReferer() const override;
41
42 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner,
43 uint32_t skip) override;
44
45 static void RecordCacheToURLMapping(const base::FilePath& path,
46 const GURL& url);
47
48 // AppIds should be be both predictable and unique, but any hash would work.
49 // Currently we use sha256 from crypto/secure_hash.h
50 static bool ComputeAppId(const base::FilePath& path,
51 std::string* digest_string);
52
53 static bool RenameToAppId(const GURL& url,
54 const base::FilePath& old_path,
55 base::FilePath* new_path);
56
57 void CopyCompleted(base::Callback<void(const base::FilePath&, bool)> callback,
58 bool success);
59
60 void AsPath(
61 base::TaskRunner* task_runner,
62 base::Callback<void(const base::FilePath&, bool)> callback) override;
63
64 std::string MimeType() override;
65
66 bool HasMojoMagic() override;
67
68 bool PeekFirstLine(std::string* line) override;
69
70 void StartNetworkRequest(mojo::URLRequestPtr request,
71 URLLoaderFactory* url_loader_factory);
72
73 void OnLoadComplete(URLResponsePtr response);
74
75 bool disable_cache_;
76 const GURL url_;
77 URLLoaderPtr url_loader_;
78 URLResponsePtr response_;
79 base::FilePath path_;
80 base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(NetworkFetcher);
83 };
84
85 } // namespace fetcher
86 } // namespace mojo
87
88 #endif // MOJO_FETCHER_NETWORK_FETCHER_H_
OLDNEW
« no previous file with comments | « mojo/fetcher/local_fetcher.cc ('k') | mojo/fetcher/network_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698