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

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

Issue 1701933004: Remove the old package manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@am2
Patch Set: . Created 4 years, 10 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/data_pipe_peek_unittest.cc ('k') | mojo/shell/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_FETCHER_H_
6 #define MOJO_SHELL_FETCHER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13
14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
15
16 class GURL;
17
18 namespace base {
19 class FilePath;
20 class TaskRunner;
21 }
22
23 namespace mojo {
24 namespace shell {
25
26 // Fetcher abstracts getting an application by either file or http[s] URL.
27 //
28 // Although it is possible to use the Network implementation for http[s] URLs
29 // (because the underlying net library knows how to handle them), it is
30 // extremely slow because network responses must be copied to disk in order to
31 // get a file handle we can use with dlopen.
32 //
33 // Until this is solved, we use two different implementations so that
34 // performance isn't completely absymal.
35 class Fetcher {
36 public:
37 // The param will be null in the case where the content could not be fetched.
38 // Reasons include:
39 // - network error
40 typedef base::Callback<void(scoped_ptr<Fetcher>)> FetchCallback;
41
42 Fetcher(const FetchCallback& fetch_callback);
43 virtual ~Fetcher();
44
45 // Returns the original URL that was fetched.
46 virtual const GURL& GetURL() const = 0;
47
48 // If the fetch resulted in a redirect, this returns the final URL after all
49 // redirects. Otherwise, it returns an empty URL.
50 virtual GURL GetRedirectURL() const = 0;
51
52 // If the fetch resulted in a redirect, this returns the referer URL to use
53 // with the redirect.
54 virtual GURL GetRedirectReferer() const = 0;
55
56 virtual URLResponsePtr AsURLResponse(base::TaskRunner* task_runner,
57 uint32_t skip) = 0;
58
59 virtual void AsPath(
60 base::TaskRunner* task_runner,
61 base::Callback<void(const base::FilePath&, bool)> callback) = 0;
62
63 virtual std::string MimeType() = 0;
64
65 virtual bool HasMojoMagic() = 0;
66
67 virtual bool PeekFirstLine(std::string* line) = 0;
68
69 bool PeekContentHandler(std::string* mojo_shebang,
70 GURL* mojo_content_handler_url);
71
72 protected:
73 static const char kMojoMagic[];
74 static const size_t kMaxShebangLength;
75
76 FetchCallback loader_callback_;
77 };
78
79 } // namespace shell
80 } // namespace mojo
81
82 #endif // MOJO_SHELL_FETCHER_H_
OLDNEW
« no previous file with comments | « mojo/shell/data_pipe_peek_unittest.cc ('k') | mojo/shell/fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698