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

Unified Diff: mojo/shell/loader.cc

Issue 323593002: Mojo: Use network service to load non-local Mojo Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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/loader.h ('k') | mojo/shell/mojo_url_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/loader.cc
diff --git a/mojo/shell/loader.cc b/mojo/shell/loader.cc
deleted file mode 100644
index d1c335545a91627d6eb6638fb3dab6b6240e3857..0000000000000000000000000000000000000000
--- a/mojo/shell/loader.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2013 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.
-
-#include "mojo/shell/loader.h"
-
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/message_loop/message_loop.h"
-#include "mojo/shell/switches.h"
-#include "net/base/load_flags.h"
-#include "net/base/network_delegate.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_fetcher.h"
-#include "net/url_request/url_request_status.h"
-
-namespace mojo {
-namespace shell {
-
-Loader::Delegate::~Delegate() {
-}
-
-Loader::Job::Job(const GURL& app_url, Delegate* delegate)
- : delegate_(delegate) {
- fetcher_.reset(net::URLFetcher::Create(app_url, net::URLFetcher::GET, this));
-}
-
-Loader::Job::~Job() {
-}
-
-void Loader::Job::OnURLFetchComplete(const net::URLFetcher* source) {
- net::URLRequestStatus status = source->GetStatus();
- if (!status.is_success()) {
- LOG(ERROR) << "URL fetch didn't succeed: status = " << status.status()
- << ", error = " << status.error();
- } else if (source->GetResponseCode() != 200) {
- // Note: We may not have a response code (e.g., if it wasn't an http: URL).
- LOG(WARNING) << "HTTP response not OK: code = "
- << source->GetResponseCode();
- }
- // TODO: Do something else in the error cases?
-
- base::FilePath app_path;
- source->GetResponseAsFilePath(true, &app_path);
- std::string mime_type;
- // We may not have response headers (e.g., if it was a file: URL).
- if (source->GetResponseHeaders())
- source->GetResponseHeaders()->GetMimeType(&mime_type);
- delegate_->DidCompleteLoad(source->GetURL(),
- app_path,
- mime_type.empty() ? NULL : &mime_type);
-}
-
-Loader::Loader(base::SingleThreadTaskRunner* network_runner,
- base::SingleThreadTaskRunner* file_runner,
- base::MessageLoopProxy* cache_runner,
- scoped_ptr<net::NetworkDelegate> network_delegate,
- base::FilePath base_path)
- : file_runner_(file_runner),
- url_request_context_getter_(new URLRequestContextGetter(
- base_path,
- network_runner,
- file_runner,
- cache_runner,
- network_delegate.Pass())) {
-}
-
-Loader::~Loader() {
-}
-
-scoped_ptr<Loader::Job> Loader::Load(const GURL& app_url, Delegate* delegate) {
- scoped_ptr<Job> job(new Job(app_url, delegate));
- job->fetcher_->SetRequestContext(url_request_context_getter_.get());
-#if defined(MOJO_SHELL_DEBUG)
- base::FilePath tmp_dir;
- base::GetTempDir(&tmp_dir);
- // If MOJO_SHELL_DEBUG is set we want to dowload to a well known location.
- // This makes it easier to do the necessary links so that symbols are found.
- job->fetcher_->SaveResponseToFileAtPath(
- tmp_dir.Append("link-me"),
- file_runner_.get());
-#else
- job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get());
-#endif
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableCache))
- job->fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
- job->fetcher_->Start();
- return job.Pass();
-}
-
-} // namespace shell
-} // namespace mojo
« no previous file with comments | « mojo/shell/loader.h ('k') | mojo/shell/mojo_url_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698