| OLD | NEW |
| 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 <list> | 5 #include <list> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" | 10 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 Status status = listeners_.front()->OnEvent( | 42 Status status = listeners_.front()->OnEvent( |
| 43 this, "HeapProfiler.addHeapSnapshotChunk", event_params); | 43 this, "HeapProfiler.addHeapSnapshotChunk", event_params); |
| 44 if (status.IsError()) | 44 if (status.IsError()) |
| 45 return status; | 45 return status; |
| 46 } | 46 } |
| 47 return Status(kOk); | 47 return Status(kOk); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Overridden from DevToolsClient: | 50 // Overridden from DevToolsClient: |
| 51 virtual Status SendCommand(const std::string& method, | 51 virtual Status SendCommand(const std::string& method, |
| 52 const base::DictionaryValue& params) OVERRIDE { | 52 const base::DictionaryValue& params) override { |
| 53 if (!disabled_) | 53 if (!disabled_) |
| 54 disabled_ = method == "Debugger.disable"; | 54 disabled_ = method == "Debugger.disable"; |
| 55 if (method == method_ && !error_after_events_) | 55 if (method == method_ && !error_after_events_) |
| 56 return Status(kUnknownError); | 56 return Status(kUnknownError); |
| 57 | 57 |
| 58 if (method == "HeapProfiler.takeHeapSnapshot") { | 58 if (method == "HeapProfiler.takeHeapSnapshot") { |
| 59 Status status = SendAddHeapSnapshotChunkEvent(); | 59 Status status = SendAddHeapSnapshotChunkEvent(); |
| 60 if (status.IsError()) | 60 if (status.IsError()) |
| 61 return status; | 61 return status; |
| 62 } | 62 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 TEST(HeapSnapshotTaker, ErrorBeforeWhenReceivingSnapshot) { | 108 TEST(HeapSnapshotTaker, ErrorBeforeWhenReceivingSnapshot) { |
| 109 DummyDevToolsClient client("HeapProfiler.takeHeapSnapshot", false); | 109 DummyDevToolsClient client("HeapProfiler.takeHeapSnapshot", false); |
| 110 HeapSnapshotTaker taker(&client); | 110 HeapSnapshotTaker taker(&client); |
| 111 scoped_ptr<base::Value> snapshot; | 111 scoped_ptr<base::Value> snapshot; |
| 112 Status status = taker.TakeSnapshot(&snapshot); | 112 Status status = taker.TakeSnapshot(&snapshot); |
| 113 ASSERT_TRUE(status.IsError()); | 113 ASSERT_TRUE(status.IsError()); |
| 114 ASSERT_FALSE(snapshot.get()); | 114 ASSERT_FALSE(snapshot.get()); |
| 115 ASSERT_TRUE(client.IsDisabled()); | 115 ASSERT_TRUE(client.IsDisabled()); |
| 116 } | 116 } |
| 117 | 117 |
| OLD | NEW |