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

Side by Side Diff: mojo/loader/loader.cc

Issue 27536014: Teach mojo_shell how to load data URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « mojo/loader/loader.h ('k') | mojo/loader/url_request_context_getter.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 (c) 2013 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 "base/message_loop/message_loop.h"
6 #include "mojo/loader/loader.h"
7 #include "mojo/loader/url_request_context_getter.h"
8 #include "net/url_request/url_fetcher.h"
9 #include "net/url_request/url_fetcher_delegate.h"
10
11 namespace mojo {
12 namespace loader {
13
14 namespace {
15
16 class FetchDelegate : public net::URLFetcherDelegate {
17 public:
18 explicit FetchDelegate(Loader::Delegate* delegate)
19 : delegate_(delegate) {
20 }
21
22 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
23
24 private:
25 Loader::Delegate* delegate_;
26 };
27
28 void FetchDelegate::OnURLFetchComplete(const net::URLFetcher* source) {
29 delegate_->DidCompleteLoad(source->GetURL());
30 delete this;
31 }
32
33 }
34
35 class Loader::Data {
36 public:
37 Data();
38 ~Data();
39
40 scoped_refptr<URLRequestContextGetter> url_request_context_getter;
41 };
42
43 Loader::Data::Data()
44 : url_request_context_getter(new URLRequestContextGetter()) {
45 }
46
47 Loader::Data::~Data() {
48 }
49
50 Loader::Loader()
51 : data_(new Data()) {
52 }
53
54 Loader::~Loader() {
55 }
56
57 void Loader::Load(const GURL& app_url, Delegate* delegate) {
58 net::URLFetcher* fetcher = net::URLFetcher::Create(
59 app_url, net::URLFetcher::GET, new FetchDelegate(delegate));
60
61 fetcher->SetRequestContext(data_->url_request_context_getter.get());
62 fetcher->Start();
63 }
64
65 } // namespace loader
66 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/loader/loader.h ('k') | mojo/loader/url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698