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

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

Issue 132283003: Mojo: Make the shell's loader log URL fetch errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: !is_success Created 6 years, 11 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "mojo/shell/loader.h" 5 #include "mojo/shell/loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/shell/switches.h" 9 #include "mojo/shell/switches.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/base/network_delegate.h" 11 #include "net/base/network_delegate.h"
12 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_request_status.h"
12 14
13 namespace mojo { 15 namespace mojo {
14 namespace shell { 16 namespace shell {
15 17
16 Loader::Delegate::~Delegate() { 18 Loader::Delegate::~Delegate() {
17 } 19 }
18 20
19 Loader::Job::Job(const GURL& app_url, Delegate* delegate) 21 Loader::Job::Job(const GURL& app_url, Delegate* delegate)
20 : delegate_(delegate) { 22 : delegate_(delegate) {
21 fetcher_.reset(net::URLFetcher::Create(app_url, net::URLFetcher::GET, this)); 23 fetcher_.reset(net::URLFetcher::Create(app_url, net::URLFetcher::GET, this));
22 } 24 }
23 25
24 Loader::Job::~Job() { 26 Loader::Job::~Job() {
25 } 27 }
26 28
27 void Loader::Job::OnURLFetchComplete(const net::URLFetcher* source) { 29 void Loader::Job::OnURLFetchComplete(const net::URLFetcher* source) {
30 net::URLRequestStatus status = source->GetStatus();
31 if (!status.is_success()) {
32 LOG(ERROR) << "URL fetch didn't succeed: status = " << status.status()
33 << ", error = " << status.error();
34 } else if (source->GetResponseCode() != 200) {
35 LOG(ERROR) << "HTTP response not OK: code = " << source->GetResponseCode();
36 }
37 // TODO: Do something else in the error cases?
38
28 base::FilePath app_path; 39 base::FilePath app_path;
29 source->GetResponseAsFilePath(true, &app_path); 40 source->GetResponseAsFilePath(true, &app_path);
30 delegate_->DidCompleteLoad(source->GetURL(), app_path); 41 delegate_->DidCompleteLoad(source->GetURL(), app_path);
31 } 42 }
32 43
33 Loader::Loader(base::SingleThreadTaskRunner* network_runner, 44 Loader::Loader(base::SingleThreadTaskRunner* network_runner,
34 base::SingleThreadTaskRunner* file_runner, 45 base::SingleThreadTaskRunner* file_runner,
35 base::MessageLoopProxy* cache_runner, 46 base::MessageLoopProxy* cache_runner,
36 scoped_ptr<net::NetworkDelegate> network_delegate, 47 scoped_ptr<net::NetworkDelegate> network_delegate,
37 base::FilePath base_path) 48 base::FilePath base_path)
(...skipping 14 matching lines...) Expand all
52 job->fetcher_->SetRequestContext(url_request_context_getter_.get()); 63 job->fetcher_->SetRequestContext(url_request_context_getter_.get());
53 job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get()); 64 job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get());
54 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableCache)) 65 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableCache))
55 job->fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 66 job->fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
56 job->fetcher_->Start(); 67 job->fetcher_->Start();
57 return job.Pass(); 68 return job.Pass();
58 } 69 }
59 70
60 } // namespace shell 71 } // namespace shell
61 } // namespace mojo 72 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698