Reland of Adding total available size of heap in v8 isolate memory dump provider.

Reason:
Now the API for available sizes is fixed and returns correct value now
(crrev.com/1141693003). So, this CL can land now.

Original issue's description (crrev.com/1129403003):
> Adding total available size of heap in v8 isolate memory dump provider.
>
> The total available size is now returned by GetHeapStatistics api.
> This CL uses the value in the dump provider to show the value in
> other_spaces segment of the memory dump.
>
> BUG=481504

Review URL: https://codereview.chromium.org/1158373002

Cr-Commit-Position: refs/heads/master@{#331952}
diff --git a/gin/v8_isolate_memory_dump_provider.cc b/gin/v8_isolate_memory_dump_provider.cc
index 4530879..8e21e74f 100644
--- a/gin/v8_isolate_memory_dump_provider.cc
+++ b/gin/v8_isolate_memory_dump_provider.cc
@@ -53,6 +53,7 @@
 
   size_t known_spaces_used_size = 0;
   size_t known_spaces_size = 0;
+  size_t known_spaces_available_size = 0;
   size_t number_of_spaces = isolate_holder_->isolate()->NumberOfHeapSpaces();
   for (size_t space = 0; space < number_of_spaces; space++) {
     v8::HeapSpaceStatistics space_statistics;
@@ -60,9 +61,11 @@
                                                        space);
     const size_t space_size = space_statistics.space_size();
     const size_t space_used_size = space_statistics.space_used_size();
+    const size_t space_available_size = space_statistics.space_available_size();
 
     known_spaces_size += space_size;
     known_spaces_used_size += space_used_size;
+    known_spaces_available_size += space_available_size;
 
     std::string allocator_name =
         base::StringPrintf("%s/%s_%p/%s/%s", kRootDumpName, kIsolateDumpName,
@@ -81,7 +84,7 @@
         base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_used_size);
     space_dump->AddScalar(kAvailableSizeAttribute,
                           base::trace_event::MemoryAllocatorDump::kUnitsBytes,
-                          space_statistics.space_available_size());
+                          space_available_size);
   }
   // Compute the rest of the memory, not accounted by the spaces above.
   std::string allocator_name = base::StringPrintf(
@@ -98,11 +101,10 @@
       base::trace_event::MemoryAllocatorDump::kUnitsBytes,
       heap_statistics.used_heap_size() - known_spaces_used_size);
 
-  // TODO(ssid): Fix crbug.com/481504 to get the total available size of the
-  // heap.
   other_spaces_dump->AddScalar(
       kAvailableSizeAttribute,
-      base::trace_event::MemoryAllocatorDump::kUnitsBytes, 0);
+      base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+      heap_statistics.total_available_size() - known_spaces_available_size);
 }
 
 }  // namespace gin