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

Unified Diff: mojo/shell/application_manager/network_fetcher.h

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/application_manager/native_runner.h ('k') | mojo/shell/application_manager/network_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/application_manager/network_fetcher.h
diff --git a/mojo/shell/application_manager/network_fetcher.h b/mojo/shell/application_manager/network_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..3ee90a951a9bd873664c6df66076afb81493b692
--- /dev/null
+++ b/mojo/shell/application_manager/network_fetcher.h
@@ -0,0 +1,83 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_
+#define SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_
+
+#include "mojo/shell/application_manager/fetcher.h"
+
+#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "mojo/services/network/public/interfaces/url_loader.mojom.h"
+#include "url/gurl.h"
+
+namespace mojo {
+
+class NetworkService;
+
+namespace shell {
+
+// Implements Fetcher for http[s] files.
+class NetworkFetcher : public Fetcher {
+ public:
+ NetworkFetcher(bool disable_cache,
+ const GURL& url,
+ NetworkService* network_service,
+ const FetchCallback& loader_callback);
+
+ ~NetworkFetcher() override;
+
+ private:
+ // TODO(hansmuller): Revisit this when a real peek operation is available.
+ static const MojoDeadline kPeekTimeout = MOJO_DEADLINE_INDEFINITE;
+
+ const GURL& GetURL() const override;
+ GURL GetRedirectURL() const override;
+
+ URLResponsePtr AsURLResponse(base::TaskRunner* task_runner,
+ uint32_t skip) override;
+
+ static void RecordCacheToURLMapping(const base::FilePath& path,
+ const GURL& url);
+
+ // AppIds should be be both predictable and unique, but any hash would work.
+ // Currently we use sha256 from crypto/secure_hash.h
+ static bool ComputeAppId(const base::FilePath& path,
+ std::string* digest_string);
+
+ static bool RenameToAppId(const GURL& url,
+ const base::FilePath& old_path,
+ base::FilePath* new_path);
+
+ void CopyCompleted(base::Callback<void(const base::FilePath&, bool)> callback,
+ bool success);
+
+ void AsPath(
+ base::TaskRunner* task_runner,
+ base::Callback<void(const base::FilePath&, bool)> callback) override;
+
+ std::string MimeType() override;
+
+ bool HasMojoMagic() override;
+
+ bool PeekFirstLine(std::string* line) override;
+
+ void StartNetworkRequest(const GURL& url, NetworkService* network_service);
+
+ void OnLoadComplete(URLResponsePtr response);
+
+ bool disable_cache_;
+ const GURL url_;
+ URLLoaderPtr url_loader_;
+ URLResponsePtr response_;
+ base::FilePath path_;
+ base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkFetcher);
+};
+
+} // namespace shell
+} // namespace mojo
+
+#endif // SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_
« no previous file with comments | « mojo/shell/application_manager/native_runner.h ('k') | mojo/shell/application_manager/network_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698