OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_SHELL_FETCHER_H_ | 5 #ifndef MOJO_SHELL_FETCHER_H_ |
6 #define MOJO_SHELL_FETCHER_H_ | 6 #define MOJO_SHELL_FETCHER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // extremely slow because network responses must be copied to disk in order to | 27 // extremely slow because network responses must be copied to disk in order to |
28 // get a file handle we can use with dlopen. | 28 // get a file handle we can use with dlopen. |
29 // | 29 // |
30 // Until this is solved, we use two different implementations so that | 30 // Until this is solved, we use two different implementations so that |
31 // performance isn't completely absymal. | 31 // performance isn't completely absymal. |
32 class Fetcher { | 32 class Fetcher { |
33 public: | 33 public: |
34 // The param will be null in the case where the content could not be fetched. | 34 // The param will be null in the case where the content could not be fetched. |
35 // Reasons include: | 35 // Reasons include: |
36 // - network error | 36 // - network error |
37 // - 4x or 5x HTTP errors | |
38 typedef base::Callback<void(scoped_ptr<Fetcher>)> FetchCallback; | 37 typedef base::Callback<void(scoped_ptr<Fetcher>)> FetchCallback; |
39 | 38 |
40 Fetcher(const FetchCallback& fetch_callback); | 39 Fetcher(const FetchCallback& fetch_callback); |
41 virtual ~Fetcher(); | 40 virtual ~Fetcher(); |
42 | 41 |
43 // Returns the original URL that was fetched. | 42 // Returns the original URL that was fetched. |
44 virtual const GURL& GetURL() const = 0; | 43 virtual const GURL& GetURL() const = 0; |
45 | 44 |
46 // If the fetch resulted in a redirect, this returns the final URL after all | 45 // If the fetch resulted in a redirect, this returns the final URL after all |
47 // redirects. Otherwise, it returns an empty URL. | 46 // redirects. Otherwise, it returns an empty URL. |
(...skipping 23 matching lines...) Expand all Loading... |
71 static const char kMojoMagic[]; | 70 static const char kMojoMagic[]; |
72 static const size_t kMaxShebangLength; | 71 static const size_t kMaxShebangLength; |
73 | 72 |
74 FetchCallback loader_callback_; | 73 FetchCallback loader_callback_; |
75 }; | 74 }; |
76 | 75 |
77 } // namespace shell | 76 } // namespace shell |
78 } // namespace mojo | 77 } // namespace mojo |
79 | 78 |
80 #endif // MOJO_SHELL_FETCHER_H_ | 79 #endif // MOJO_SHELL_FETCHER_H_ |
OLD | NEW |