summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_about_job.cc
blob: 242a7357460f7afee0f229ff40e7b62736ef6e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 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.

// Simple implementation of about: protocol handler that treats everything as
// about:blank.  No other about: features should be available to web content,
// so they're not implemented here.

#include "net/url_request/url_request_about_job.h"

#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"

namespace net {

URLRequestAboutJob::URLRequestAboutJob(URLRequest* request,
                                       NetworkDelegate* network_delegate)
    : URLRequestJob(request, network_delegate),
      ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}

// static
URLRequestJob* URLRequestAboutJob::Factory(URLRequest* request,
                                           NetworkDelegate* network_delegate,
                                           const std::string& scheme) {
  return new URLRequestAboutJob(request, network_delegate);
}

void URLRequestAboutJob::Start() {
  // Start reading asynchronously so that all error reporting and data
  // callbacks happen as they would for network requests.
  MessageLoop::current()->PostTask(
      FROM_HERE,
      base::Bind(&URLRequestAboutJob::StartAsync, weak_factory_.GetWeakPtr()));
}

bool URLRequestAboutJob::GetMimeType(std::string* mime_type) const {
  *mime_type = "text/html";
  return true;
}

URLRequestAboutJob::~URLRequestAboutJob() {
}

void URLRequestAboutJob::StartAsync() {
  NotifyHeadersComplete();
}

}  // namespace net