<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_host/test_render_view_host.h"
#include "chrome/common/render_messages.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// RenderWidgetHostProcess -----------------------------------------------------

class RenderWidgetHostProcess : public MockRenderProcessHost {
 public:
  explicit RenderWidgetHostProcess(Profile* profile)
      : MockRenderProcessHost(profile),
        current_paint_buf_(NULL),
        paint_msg_should_reply_(false),
        paint_msg_reply_flags_(0) {
    // DANGER! This is a hack. The RenderWidgetHost checks the channel to see
    // if the process is still alive, but it doesn't actually dereference it.
    // An IPC::SyncChannel is nontrivial, so we just fake it here. If you end up
    // crashing by dereferencing 1, then you'll have to make a real channel.
    channel_.reset(reinterpret_cast<IPC::SyncChannel*>(0x1));
  }
  ~RenderWidgetHostProcess() {
    // We don't want to actually delete the channel, since it's not a real
    // pointer.
    channel_.release();
  }

  void set_paint_msg_should_reply(bool reply) {
    paint_msg_should_reply_ = reply;
  }
  void set_paint_msg_reply_flags(int flags) {
    paint_msg_reply_flags_ = flags;
  }

  // Fills the given paint parameters with resonable default values.
  void InitPaintRectParams(ViewHostMsg_PaintRect_Params* params);

 protected:
  virtual bool WaitForPaintMsg(int render_widget_id,
                               const base::TimeDelta& max_delay,
                               IPC::Message* msg);

  TransportDIB* current_paint_buf_;

  // Set to true when WaitForPaintMsg should return a successful paint messaage
  // reply. False implies timeout.
  bool paint_msg_should_reply_;<commit_msg>Purify fix<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_host/test_render_view_host.h"
#include "chrome/common/render_messages.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// RenderWidgetHostProcess -----------------------------------------------------

class RenderWidgetHostProcess : public MockRenderProcessHost {
 public:
  explicit RenderWidgetHostProcess(Profile* profile)
      : MockRenderProcessHost(profile),
        current_paint_buf_(NULL),
        paint_msg_should_reply_(false),
        paint_msg_reply_flags_(0) {
    // DANGER! This is a hack. The RenderWidgetHost checks the channel to see
    // if the process is still alive, but it doesn't actually dereference it.
    // An IPC::SyncChannel is nontrivial, so we just fake it here. If you end up
    // crashing by dereferencing 1, then you'll have to make a real channel.
    channel_.reset(reinterpret_cast<IPC::SyncChannel*>(0x1));
  }
  ~RenderWidgetHostProcess() {
    // We don't want to actually delete the channel, since it's not a real
    // pointer.
    channel_.release();
    if (current_paint_buf_)
      delete current_paint_buf_;
  }

  void set_paint_msg_should_reply(bool reply) {
    paint_msg_should_reply_ = reply;
  }
  void set_paint_msg_reply_flags(int flags) {
    paint_msg_reply_flags_ = flags;
  }

  // Fills the given paint parameters with resonable default values.
  void InitPaintRectParams(ViewHostMsg_PaintRect_Params* params);

 protected:
  virtual bool WaitForPaintMsg(int render_widget_id,
                               const base::TimeDelta& max_delay,
                               IPC::Message* msg);

  TransportDIB* current_paint_buf_;

  // Set to true when WaitForPaintMsg should return a successful paint messaage
  // reply. False implies timeout.
  bool paint_msg_should_reply_;
{'fraction_non_alphanumeric': 0.10643921191734743, 'fraction_numerical': 0.0038443056222969728, 'mean_word_length': 3.205050505050505, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1789627', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1211, 'n_words': 354}