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

Side by Side Diff: mojo/fetcher/base_application_fetcher.cc

Issue 1342503003: 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/fetcher/base_application_fetcher.h ('k') | mojo/fetcher/local_fetcher.h » ('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 #include "mojo/fetcher/base_application_fetcher.h"
6
7 #include "mojo/fetcher/about_fetcher.h"
8 #include "mojo/fetcher/local_fetcher.h"
9 #include "mojo/fetcher/network_fetcher.h"
10 #include "mojo/fetcher/switches.h"
11 #include "mojo/fetcher/update_fetcher.h"
12 #include "mojo/shell/application_manager.h"
13 #include "mojo/shell/query_util.h"
14 #include "mojo/util/filename_util.h"
15 #include "url/gurl.h"
16
17 namespace mojo {
18 namespace fetcher {
19
20 BaseApplicationFetcher::BaseApplicationFetcher(
21 const base::FilePath& shell_file_root)
22 : application_manager_(nullptr),
23 disable_cache_(base::CommandLine::ForCurrentProcess()->HasSwitch(
24 switches::kDisableCache)) {
25 if (!shell_file_root.empty()) {
26 GURL mojo_root_file_url =
27 util::FilePathToFileURL(shell_file_root).Resolve(std::string());
28 url_resolver_.reset(new URLResolver(mojo_root_file_url));
29 }
30 }
31
32 BaseApplicationFetcher::~BaseApplicationFetcher() {
33 }
34
35 void BaseApplicationFetcher::SetApplicationManager(
36 shell::ApplicationManager* manager) {
37 application_manager_ = manager;
38 }
39
40 GURL BaseApplicationFetcher::ResolveURL(const GURL& url) {
41 return url_resolver_.get() ? url_resolver_->ResolveMojoURL(url) : url;
42 }
43
44 void BaseApplicationFetcher::FetchRequest(
45 URLRequestPtr request,
46 const shell::Fetcher::FetchCallback& loader_callback) {
47 GURL url(request->url);
48 if (url.SchemeIs(AboutFetcher::kAboutScheme)) {
49 AboutFetcher::Start(url, loader_callback);
50 return;
51 }
52
53 GURL resolved_url = ResolveURL(url);
54
55 if (resolved_url.SchemeIsFile()) {
56 // LocalFetcher uses the network service to infer MIME types from URLs.
57 // Skip this for mojo URLs to avoid recursively loading the network service.
58 if (!network_service_ && !url.SchemeIs("mojo")) {
59 application_manager_->ConnectToService(GURL("mojo:network_service"),
60 &network_service_);
61 }
62 // Ownership of this object is transferred to |loader_callback|.
63 // TODO(beng): this is eff'n weird.
64 new LocalFetcher(
65 network_service_.get(), resolved_url,
66 shell::GetBaseURLAndQuery(resolved_url, nullptr),
67 loader_callback);
68 return;
69 }
70
71 #if 0
72 // TODO(beng): figure out how this should be integrated now that mapped_url
73 // is toast.
74 // TODO(scottmg): to quote someone I know, if you liked this you shouldda put
75 // a test on it.
76 if (url.SchemeIs("mojo") &&
77 base::CommandLine::ForCurrentProcess()->HasSwitch(
78 switches::kUseUpdater)) {
79 application_manager_->ConnectToService(GURL("mojo:updater"), &updater_);
80 // Ownership of this object is transferred to |loader_callback|.
81 // TODO(beng): this is eff'n weird.
82 new UpdateFetcher(url, updater_.get(), loader_callback);
83 return;
84 }
85 #endif
86
87 if (!url_loader_factory_) {
88 application_manager_->ConnectToService(GURL("mojo:network_service"),
89 &url_loader_factory_);
90 }
91
92 // Ownership of this object is transferred to |loader_callback|.
93 // TODO(beng): this is eff'n weird.
94 new NetworkFetcher(disable_cache_, request.Pass(), url_loader_factory_.get(),
95 loader_callback);
96 }
97
98 } // namespace fetcher
99 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/fetcher/base_application_fetcher.h ('k') | mojo/fetcher/local_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698