| Index: content/browser/renderer_host/media/video_capture_controller_unittest.cc
 | 
| diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
 | 
| index d27fac393e88fd61ca43896cf1fba85ebbd5e701..4dbec58f58129001b9b7c7ac4ae01d33c58e79cf 100644
 | 
| --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
 | 
| +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
 | 
| @@ -23,6 +23,7 @@
 | 
|  #include "content/public/test/test_browser_thread_bundle.h"
 | 
|  #include "gpu/command_buffer/common/mailbox_holder.h"
 | 
|  #include "media/base/video_capture_types.h"
 | 
| +#include "media/base/video_frame_metadata.h"
 | 
|  #include "media/base/video_util.h"
 | 
|  #include "testing/gmock/include/gmock/gmock.h"
 | 
|  #include "testing/gtest/include/gtest/gtest.h"
 | 
| @@ -43,7 +44,8 @@ class MockVideoCaptureControllerEventHandler
 | 
|   public:
 | 
|    explicit MockVideoCaptureControllerEventHandler(
 | 
|        VideoCaptureController* controller)
 | 
| -      : controller_(controller) {}
 | 
| +      : controller_(controller),
 | 
| +        resource_utilization_(-1.0) {}
 | 
|    ~MockVideoCaptureControllerEventHandler() override {}
 | 
|  
 | 
|    // These mock methods are delegated to by our fake implementation of
 | 
| @@ -77,7 +79,12 @@ class MockVideoCaptureControllerEventHandler
 | 
|      base::ThreadTaskRunnerHandle::Get()->PostTask(
 | 
|          FROM_HERE,
 | 
|          base::Bind(&VideoCaptureController::ReturnBuffer,
 | 
| -                   base::Unretained(controller_), id, this, buffer_id, 0));
 | 
| +                   base::Unretained(controller_),
 | 
| +                   id,
 | 
| +                   this,
 | 
| +                   buffer_id,
 | 
| +                   0,
 | 
| +                   resource_utilization_));
 | 
|    }
 | 
|    void OnMailboxBufferReady(
 | 
|        VideoCaptureControllerID id,
 | 
| @@ -88,9 +95,14 @@ class MockVideoCaptureControllerEventHandler
 | 
|        scoped_ptr<base::DictionaryValue> metadata) override {
 | 
|      DoMailboxBufferReady(id);
 | 
|      base::ThreadTaskRunnerHandle::Get()->PostTask(
 | 
| -        FROM_HERE, base::Bind(&VideoCaptureController::ReturnBuffer,
 | 
| -                              base::Unretained(controller_), id, this,
 | 
| -                              buffer_id, mailbox_holder.sync_point));
 | 
| +        FROM_HERE,
 | 
| +        base::Bind(&VideoCaptureController::ReturnBuffer,
 | 
| +                   base::Unretained(controller_),
 | 
| +                   id,
 | 
| +                   this,
 | 
| +                   buffer_id,
 | 
| +                   mailbox_holder.sync_point,
 | 
| +                   resource_utilization_));
 | 
|    }
 | 
|    void OnEnded(VideoCaptureControllerID id) override {
 | 
|      DoEnded(id);
 | 
| @@ -102,6 +114,7 @@ class MockVideoCaptureControllerEventHandler
 | 
|    }
 | 
|  
 | 
|    VideoCaptureController* controller_;
 | 
| +  double resource_utilization_;
 | 
|  };
 | 
|  
 | 
|  // Test class.
 | 
| @@ -336,12 +349,23 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
 | 
|    }
 | 
|    scoped_refptr<media::VideoFrame> video_frame =
 | 
|        WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer->data()));
 | 
| +  ASSERT_FALSE(video_frame->metadata()->HasKey(
 | 
| +      media::VideoFrameMetadata::RESOURCE_UTILIZATION));
 | 
| +  client_a_->resource_utilization_ = 0.5;
 | 
| +  client_b_->resource_utilization_ = -1.0;
 | 
|    device_->OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame,
 | 
|                                          base::TimeTicks());
 | 
|  
 | 
|    base::RunLoop().RunUntilIdle();
 | 
|    Mock::VerifyAndClearExpectations(client_a_.get());
 | 
|    Mock::VerifyAndClearExpectations(client_b_.get());
 | 
| +  // Expect VideoCaptureController set the metadata in |video_frame| to hold a
 | 
| +  // resource utilization of 0.5 (the largest of all reported values).
 | 
| +  double resource_utilization_in_metadata = -1.0;
 | 
| +  ASSERT_TRUE(video_frame->metadata()->GetDouble(
 | 
| +      media::VideoFrameMetadata::RESOURCE_UTILIZATION,
 | 
| +      &resource_utilization_in_metadata));
 | 
| +  ASSERT_EQ(0.5, resource_utilization_in_metadata);
 | 
|  
 | 
|    // Second buffer which ought to use the same shared memory buffer. In this
 | 
|    // case pretend that the Buffer pointer is held by the device for a long
 | 
| @@ -353,6 +377,10 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
 | 
|    memset(buffer2->data(), buffer_no++, buffer2->size());
 | 
|    video_frame =
 | 
|        WrapI420Buffer(capture_resolution, static_cast<uint8*>(buffer2->data()));
 | 
| +  ASSERT_FALSE(video_frame->metadata()->HasKey(
 | 
| +      media::VideoFrameMetadata::RESOURCE_UTILIZATION));
 | 
| +  client_a_->resource_utilization_ = 0.5;
 | 
| +  client_b_->resource_utilization_ = 3.14;
 | 
|    device_->OnIncomingCapturedVideoFrame(buffer2.Pass(), video_frame,
 | 
|                                          base::TimeTicks());
 | 
|  
 | 
| @@ -363,6 +391,13 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
 | 
|    base::RunLoop().RunUntilIdle();
 | 
|    Mock::VerifyAndClearExpectations(client_a_.get());
 | 
|    Mock::VerifyAndClearExpectations(client_b_.get());
 | 
| +  // Expect VideoCaptureController set the metadata in |video_frame| to hold a
 | 
| +  // resource utilization of 3.14 (the largest of all reported values).
 | 
| +  resource_utilization_in_metadata = -1.0;
 | 
| +  ASSERT_TRUE(video_frame->metadata()->GetDouble(
 | 
| +      media::VideoFrameMetadata::RESOURCE_UTILIZATION,
 | 
| +      &resource_utilization_in_metadata));
 | 
| +  ASSERT_EQ(3.14, resource_utilization_in_metadata);
 | 
|  
 | 
|    // Add a fourth client now that some buffers have come through.
 | 
|    controller_->AddClient(client_b_route_2,
 | 
| 
 |