OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/web_resource/json_asynchronous_unpacker.h" | 5 #include "chrome/browser/web_resource/json_asynchronous_unpacker.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/web_resource/web_resource_service.h" | 8 #include "chrome/browser/web_resource/web_resource_service.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/chrome_utility_messages.h" | 10 #include "chrome/common/chrome_utility_messages.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class JSONAsynchronousUnpackerImpl | 24 class JSONAsynchronousUnpackerImpl |
25 : public UtilityProcessHostClient, | 25 : public UtilityProcessHostClient, |
26 public JSONAsynchronousUnpacker { | 26 public JSONAsynchronousUnpacker { |
27 public: | 27 public: |
28 explicit JSONAsynchronousUnpackerImpl( | 28 explicit JSONAsynchronousUnpackerImpl( |
29 JSONAsynchronousUnpackerDelegate* delegate) | 29 JSONAsynchronousUnpackerDelegate* delegate) |
30 : JSONAsynchronousUnpacker(delegate), | 30 : JSONAsynchronousUnpacker(delegate), |
31 got_response_(false) { | 31 got_response_(false) { |
32 } | 32 } |
33 | 33 |
34 void Start(const std::string& json_data) { | 34 virtual void Start(const std::string& json_data) OVERRIDE { |
35 AddRef(); // balanced in Cleanup. | 35 AddRef(); // balanced in Cleanup. |
36 | 36 |
37 // TODO(willchan): Look for a better signal of whether we're in a unit test | 37 // TODO(willchan): Look for a better signal of whether we're in a unit test |
38 // or not. Using |ResourceDispatcherHost::Get()| for this is pretty lame. | 38 // or not. Using |ResourceDispatcherHost::Get()| for this is pretty lame. |
39 // If we don't have a ResourceDispatcherHost, assume we're in a test and | 39 // If we don't have a ResourceDispatcherHost, assume we're in a test and |
40 // run the unpacker directly in-process. | 40 // run the unpacker directly in-process. |
41 bool use_utility_process = | 41 bool use_utility_process = |
42 content::ResourceDispatcherHost::Get() && | 42 content::ResourceDispatcherHost::Get() && |
43 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 43 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
44 if (use_utility_process) { | 44 if (use_utility_process) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // True if we got a response from the utility process and have cleaned up | 116 // True if we got a response from the utility process and have cleaned up |
117 // already. | 117 // already. |
118 bool got_response_; | 118 bool got_response_; |
119 }; | 119 }; |
120 | 120 |
121 JSONAsynchronousUnpacker* JSONAsynchronousUnpacker::Create( | 121 JSONAsynchronousUnpacker* JSONAsynchronousUnpacker::Create( |
122 JSONAsynchronousUnpackerDelegate* delegate) { | 122 JSONAsynchronousUnpackerDelegate* delegate) { |
123 return new JSONAsynchronousUnpackerImpl(delegate); | 123 return new JSONAsynchronousUnpackerImpl(delegate); |
124 } | 124 } |
125 | 125 |
OLD | NEW |