url_request_about_job.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1// Copyright (c) 2012 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// Simple implementation of about: protocol handler that treats everything as
6// about:blank.  No other about: features should be available to web content,
7// so they're not implemented here.
8
9#include "net/url_request/url_request_about_job.h"
10
11#include "base/bind.h"
12#include "base/compiler_specific.h"
13#include "base/message_loop.h"
14
15namespace net {
16
17URLRequestAboutJob::URLRequestAboutJob(URLRequest* request,
18                                       NetworkDelegate* network_delegate)
19    : URLRequestJob(request, network_delegate),
20      weak_factory_(this) {
21}
22
23// static
24URLRequestJob* URLRequestAboutJob::Factory(URLRequest* request,
25                                           NetworkDelegate* network_delegate,
26                                           const std::string& scheme) {
27  return new URLRequestAboutJob(request, network_delegate);
28}
29
30void URLRequestAboutJob::Start() {
31  // Start reading asynchronously so that all error reporting and data
32  // callbacks happen as they would for network requests.
33  MessageLoop::current()->PostTask(
34      FROM_HERE,
35      base::Bind(&URLRequestAboutJob::StartAsync, weak_factory_.GetWeakPtr()));
36}
37
38bool URLRequestAboutJob::GetMimeType(std::string* mime_type) const {
39  *mime_type = "text/html";
40  return true;
41}
42
43URLRequestAboutJob::~URLRequestAboutJob() {
44}
45
46void URLRequestAboutJob::StartAsync() {
47  NotifyHeadersComplete();
48}
49
50}  // namespace net
51