Files
palemoon27/toolkit/devtools/server/ZeroCopyNSIOutputStream.cpp
T
roytam1 6629d22907 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1170717 - Move heapState check up to readBarrier; r=jonco (b9c4df5ea)
- Bug 1163908 - Export GL draw data to layerscope for drawing heat-map view. r=:djg (cf078d4fd)
- Bug 1161372 - Add EventRegions on LayerScope. r=dglastonbury (49fc29e8a)
- Files as of Bug 1138721 - Application reputation should check mac file extensions. r=mmc (4b76de8d8)
- Bug 1024774 - Part 0: Upgrade the protobuf library. r=mmc,glandium (c98c08fbd)
- Bug 1149397 - JS::ubi::Node::edges should return a mozilla::UniquePtr; r=jimb (32f755867)
- Bug 1110039 - Part 1 - Add nsLayoutUtils::ClampRectToScrollFrames. r=roc (a8812c287)
- Bug 1110039 - Part 2.1 - Add logger facility. r=roc (1a400bb1f)
- Bug 1110039 - Part 2.2 - Add AccessibleCaret. r=roc (d8c2c759f)
- Bug 1110039 - Part 2.3 - Add AccessibleCaretManager. r=roc (ba8ad6424)
- Bug 1110039 - Part 2.4 - Add AccessibleCaretEventHub. r=roc (db4ef1fe6)
- Bug 1110039 - Part 2.5 - Add all files to build system. r=roc (bee54dc43)
- fix nsRefPtr includes - but build still broken (423d9f32d)
- Bug 1110039 - Part 3 - Add gtest for AccessibleCaretEventHub. r=roc (cdf0df240)
- Bug 1110039 - Part 4 - Hook new classes into the system. r=roc (438a4df68)
- Bug 1109183 - Fix imports of the marionette client and remove spurious entry from sys.path provided by mach. r=ahal (86b814562)
- Bug 1110039 - Part 5 - Reuse marionette tests for AccessibleCaret. r=roc (d5cd35016)
- Bug 1110039 followup: Add 'override' keyword to Name() decl in Access# (cd0d9b0f6)
- Bug 1140994 - Notify gaia to hide selection bubble when scrolling without APZ. r=roc (ca15626fa)
- Bug 1143665 - Remove the ambiguous scroll position being passed around in scroll started/stop notifications. r=roc,ehsan (ce8f1d2a9)
- Bug 1140238 - Part 1: Add a test to drag first caret over non-selectable. r=automatedtester (4080723fe)
- Bug 1140238 - Part 2: Adjust ranges after changing selection direction. r=mats (add1f155d)
- Bug 1140238 - Part 3: Clear maintain selection when dragging caret. r=mats (0aba36f24)
- Bug 1024774 - Part 2: Implement a google::protobuf::ZeroCopyOutputStream wrapper around nsIOutputStream; r=jimb (30c6272d2)
- Bug 1024774 - Part 3: Serialize heap snapshots. r=jimb (9d0c8f6ec)
- Bug 1024774 - Part 1: Add the ChromeUtils WebIDL interface. r=bholley (8e81e8344)
- Bug 1024774 - Part 4: Add an xpcshell test for saving heap snapshots. r=jimb (6e0a07069)
- Bug 1024774 - Part 5: Add GTests for core dump serialization. r=jimb (79315c540)
- clean up spurious char (9a1f9bc18)
- Bug 1121528 - Avoid the inspector going blank when quickly navigating; r=bgrins (f4cff269f)
- Bug 1155168 - Always use the same actor pool. r=ochameau (3e6cc5504)
- Bug 1137527 - Part 1: Make the memory actor emit events for garbage collection. r=jryans (6dcdb18f8)
- Bug 1137527 - Part 2: Add a test for GC MemoryActor events. r=jryans (df2bcf120)
- Bug 1024774 - Part 6: Add a mochitest-chrome sanity check test. r=bholley (4b5bffe79)
- Bug 1024774 - Part 7: Add HeapSnapshot WebIDL interface; r=bholley (7b5ae703a)
- Bug 1024774 - Part 8: Add JS::ubi::Node::isLive; r=jimb (42a965f56)
- Bug 1024774 - Part 9: Deserialize heap snapshots; r=jimb (fb3edfbc0)
- Bug 1024774 - Part 10: Add an xpcshell test for reading heap snapshots. r=jimb (09c3390a1)
- Bug 1024774 - Part 11: Implement a JS::ubi::Node specialization for DeserializedNode; r=jimb (d73362efe)
- Bug 1024774 - Part 12: Add a GTest for the JS::ubi::Node specialization for DeserializedNode; r=jimb (4415acb73)
- Bug 1024774 - Part 13: Change to new SpiderMonkey style from bug 1144366; r=me (15c4bcf87)
- Bug 1024774 - Part 14: Ignore protobuf indirect calls in the GC hazard analysis; r=sfink (c5b141c59)
- Bug 1024774 - Followup: Don't redefine the Debugger property in xpcshell tests; r=jorendorff (dc4f1f109)
- Bug 1169791 - Strongly type NoteJSRoot; r=mccr8 (ba722a44f)
- Bug 1169791 - Strongly type MergeZone; r=mccr8 (a118cf612)
- Bug 1169791 - Strongly type GetTenuredGCThingZone; r=jonco, r=mccr8 (a4da82aea)
- Bug 1171780 - We no longer need to cast out of barrieried types in GC; r=jonco (be83218fa)
- Bug 1144361: Re-enable JIT code randomization on Win64. r=jandem (6c88b4312)
- pointer style (458344bcd)
- Bug 1156914 - Fix the MacroAssembler::pushValue(const Address&) footgun on 32 bit platforms. (r=jandem) (52d5c351d)
- Bug 1156030 - Remove some obsolete static assertion macros from the tree; r=Waldo (84d8f3fea)
- pointer style (ac3c92ce1)
- Bug 1151323 - Handle loading unboxed int32 properties into floating point registers, r=jandem. (790920f3d)
- Bug 1023297 - Use explicit constructors for ARM-specific classes. r=jandem (f7f12cd76)
- Bug 1164229 - Rename ARM SetCond_ to SBit. r=efaust (c55e1d535)
- Bug 977805 - Add an option to mark JIT pages as non-writable. r=luke bug 977805 - add missing #include. r=jandem (384abd6ad)
- Bug 1173992 - Add ARM64 build support. r=glandium (540a7c784)
- Bug 1170750 - Replace %f by %.16g in js/src. r=jandem (48f808c73)
- Bug 1170750 - Use mfbt snprintf_literal instead of sprintf. r=jandem (3b2016484)
- Bug 1170750 - jsprf.cpp: Sort headers properly. r=me (0956cd3a5)
- Bug 923717 - Use structured control flow when testing for the forceInlineCaches option, r=nbp. (fc1dcef6e)
- Bug 1158044 - Remove unused TypeWrapper class and untemplatize/cleanup some code. r=bhackett (a4d5de646)
- Bug 1169355 - Remove unnecessary assertion, r=jandem. (f55c99552)
- Bug 1162986 - Allow objects to be turned into singletons dynamically, r=jandem. (9c683e420)
- Bug 1169731 - [[Call]] on a class constructor should throw. (r=jandem) (470895e3f)
and fix for shared-js in UbiNode.h
2020-11-09 23:37:50 +08:00

100 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
#include "mozilla/DebugOnly.h"
namespace mozilla {
namespace devtools {
ZeroCopyNSIOutputStream::ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream>& out)
: out(out)
, result_(NS_OK)
, amountUsed(0)
, writtenCount(0)
{
DebugOnly<bool> nonBlocking = false;
MOZ_ASSERT(out->IsNonBlocking(&nonBlocking) == NS_OK);
MOZ_ASSERT(!nonBlocking);
}
ZeroCopyNSIOutputStream::~ZeroCopyNSIOutputStream()
{
if (!failed())
NS_WARN_IF(NS_FAILED(writeBuffer()));
}
nsresult
ZeroCopyNSIOutputStream::writeBuffer()
{
if (failed())
return result_;
if (amountUsed == 0)
return NS_OK;
int32_t amountWritten = 0;
while (amountWritten < amountUsed) {
uint32_t justWritten = 0;
result_ = out->Write(buffer + amountWritten,
amountUsed - amountWritten,
&justWritten);
if (NS_WARN_IF(NS_FAILED(result_)))
return result_;
amountWritten += justWritten;
}
writtenCount += amountUsed;
amountUsed = 0;
return NS_OK;
}
// ZeroCopyOutputStream Interface
bool
ZeroCopyNSIOutputStream::Next(void** data, int* size)
{
MOZ_ASSERT(data != nullptr);
MOZ_ASSERT(size != nullptr);
if (failed())
return false;
if (amountUsed == BUFFER_SIZE) {
if (NS_FAILED(writeBuffer()))
return false;
}
*data = buffer + amountUsed;
*size = BUFFER_SIZE - amountUsed;
amountUsed = BUFFER_SIZE;
return true;
}
void
ZeroCopyNSIOutputStream::BackUp(int count)
{
MOZ_ASSERT(count > 0,
"Must back up a positive number of bytes.");
MOZ_ASSERT(amountUsed == BUFFER_SIZE,
"Can only call BackUp directly after calling Next.");
MOZ_ASSERT(count <= amountUsed,
"Can't back up further than we've given out.");
amountUsed -= count;
}
::google::protobuf::int64
ZeroCopyNSIOutputStream::ByteCount() const
{
return writtenCount + amountUsed;
}
} // namespace devtools
} // namespace mozilla