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

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

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

Powered by Google App Engine
This is Rietveld 408576698